Added back explicit state/node creation when visiting IntegerLiterals and
CharacterLiterals. This may not be a permanent solution; it doesn't cost that much, however, to create a few additional states, and solves a whole bunch of edge cases when handling ?, ||, and &&. llvm-svn: 47299
This commit is contained in:
		
							parent
							
								
									e0188e6ad7
								
							
						
					
					
						commit
						8b51dc2754
					
				| 
						 | 
					@ -839,7 +839,7 @@ void GRExprEngine::Visit(Stmt* S, NodeTy* Pred, NodeSet& Dst) {
 | 
				
			||||||
      
 | 
					      
 | 
				
			||||||
    default:
 | 
					    default:
 | 
				
			||||||
      // Cases we intentionally have "default" handle:
 | 
					      // Cases we intentionally have "default" handle:
 | 
				
			||||||
      //   AddrLabelExpr, CharacterLiteral, IntegerLiteral
 | 
					      //   AddrLabelExpr
 | 
				
			||||||
      
 | 
					      
 | 
				
			||||||
      Dst.Add(Pred); // No-op. Simply propagate the current state unchanged.
 | 
					      Dst.Add(Pred); // No-op. Simply propagate the current state unchanged.
 | 
				
			||||||
      break;
 | 
					      break;
 | 
				
			||||||
| 
						 | 
					@ -873,6 +873,19 @@ void GRExprEngine::Visit(Stmt* S, NodeTy* Pred, NodeSet& Dst) {
 | 
				
			||||||
      break;
 | 
					      break;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
      
 | 
					      
 | 
				
			||||||
 | 
					      // While explicitly creating a node+state for visiting a CharacterLiteral
 | 
				
			||||||
 | 
					      // seems wasteful, it also solves a bunch of problems when handling
 | 
				
			||||||
 | 
					      // the ?, &&, and ||.
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
 | 
					    case Stmt::CharacterLiteralClass: {
 | 
				
			||||||
 | 
					      CharacterLiteral* C = cast<CharacterLiteral>(S);
 | 
				
			||||||
 | 
					      StateTy St = Pred->getState();
 | 
				
			||||||
 | 
					      NonLValue X = NonLValue::GetValue(ValMgr, C->getValue(), C->getType(),
 | 
				
			||||||
 | 
					                                        C->getLoc());
 | 
				
			||||||
 | 
					      Nodify(Dst, C, Pred, SetValue(St, C, X));
 | 
				
			||||||
 | 
					      break;      
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
    case Stmt::ChooseExprClass: { // __builtin_choose_expr
 | 
					    case Stmt::ChooseExprClass: { // __builtin_choose_expr
 | 
				
			||||||
      ChooseExpr* C = cast<ChooseExpr>(S);
 | 
					      ChooseExpr* C = cast<ChooseExpr>(S);
 | 
				
			||||||
      VisitGuardedExpr(C, C->getLHS(), C->getRHS(), Pred, Dst);
 | 
					      VisitGuardedExpr(C, C->getLHS(), C->getRHS(), Pred, Dst);
 | 
				
			||||||
| 
						 | 
					@ -897,6 +910,18 @@ void GRExprEngine::Visit(Stmt* S, NodeTy* Pred, NodeSet& Dst) {
 | 
				
			||||||
      VisitDeclStmt(cast<DeclStmt>(S), Pred, Dst);
 | 
					      VisitDeclStmt(cast<DeclStmt>(S), Pred, Dst);
 | 
				
			||||||
      break;
 | 
					      break;
 | 
				
			||||||
      
 | 
					      
 | 
				
			||||||
 | 
					      // While explicitly creating a node+state for visiting an IntegerLiteral
 | 
				
			||||||
 | 
					      // seems wasteful, it also solves a bunch of problems when handling
 | 
				
			||||||
 | 
					      // the ?, &&, and ||.
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
 | 
					    case Stmt::IntegerLiteralClass: {      
 | 
				
			||||||
 | 
					      StateTy St = Pred->getState();
 | 
				
			||||||
 | 
					      IntegerLiteral* I = cast<IntegerLiteral>(S);
 | 
				
			||||||
 | 
					      NonLValue X = NonLValue::GetValue(ValMgr, I);
 | 
				
			||||||
 | 
					      Nodify(Dst, I, Pred, SetValue(St, I, X));
 | 
				
			||||||
 | 
					      break;      
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
    case Stmt::ImplicitCastExprClass: {
 | 
					    case Stmt::ImplicitCastExprClass: {
 | 
				
			||||||
      ImplicitCastExpr* C = cast<ImplicitCastExpr>(S);
 | 
					      ImplicitCastExpr* C = cast<ImplicitCastExpr>(S);
 | 
				
			||||||
      VisitCast(C, C->getSubExpr(), Pred, Dst);
 | 
					      VisitCast(C, C->getSubExpr(), Pred, Dst);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -232,7 +232,7 @@ RValue ValueStateManager::GetValue(ValueState St, Expr* E, bool* hasVal) {
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
        // Integer literals evaluate to an RValue.  Simply retrieve the
 | 
					        // Integer literals evaluate to an RValue.  Simply retrieve the
 | 
				
			||||||
        // RValue for the literal.
 | 
					        // RValue for the literal.
 | 
				
			||||||
        
 | 
					#if 0        
 | 
				
			||||||
      case Stmt::IntegerLiteralClass:
 | 
					      case Stmt::IntegerLiteralClass:
 | 
				
			||||||
        return NonLValue::GetValue(ValMgr, cast<IntegerLiteral>(E));
 | 
					        return NonLValue::GetValue(ValMgr, cast<IntegerLiteral>(E));
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
| 
						 | 
					@ -242,6 +242,7 @@ RValue ValueStateManager::GetValue(ValueState St, Expr* E, bool* hasVal) {
 | 
				
			||||||
        return NonLValue::GetValue(ValMgr, C->getValue(), C->getType(),
 | 
					        return NonLValue::GetValue(ValMgr, C->getValue(), C->getType(),
 | 
				
			||||||
                                   C->getLoc());
 | 
					                                   C->getLoc());
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					#endif        
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // Casts where the source and target type are the same
 | 
					        // Casts where the source and target type are the same
 | 
				
			||||||
        // are no-ops.  We blast through these to get the descendant
 | 
					        // are no-ops.  We blast through these to get the descendant
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue