diff options
| author | John McCall <rjmccall@apple.com> | 2010-05-07 05:46:35 +0000 | 
|---|---|---|
| committer | John McCall <rjmccall@apple.com> | 2010-05-07 05:46:35 +0000 | 
| commit | f0c4f356b866c3d84b99a3abd692b30dcaf51b5f (patch) | |
| tree | a93a95fa067e662e695ba45d549667a28a5684d2 | |
| parent | 864e396d0b55d48d351f8e4259b2cf0bfaa58e1d (diff) | |
| download | bcm5719-llvm-f0c4f356b866c3d84b99a3abd692b30dcaf51b5f.tar.gz bcm5719-llvm-f0c4f356b866c3d84b99a3abd692b30dcaf51b5f.zip  | |
Change Evaluate* in the constant evaluator to enforce being given an argument of
the right type.  It turns out that the code was already doing this.
llvm-svn: 103238
| -rw-r--r-- | clang/lib/AST/ExprConstant.cpp | 11 | 
1 files changed, 6 insertions, 5 deletions
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp index f6e0c29d8dc..30ef6f3aec8 100644 --- a/clang/lib/AST/ExprConstant.cpp +++ b/clang/lib/AST/ExprConstant.cpp @@ -395,8 +395,7 @@ public:  } // end anonymous namespace  static bool EvaluatePointer(const Expr* E, APValue& Result, EvalInfo &Info) { -  if (!E->getType()->hasPointerRepresentation()) -    return false; +  assert(E->getType()->hasPointerRepresentation());    Result = PointerExprEvaluator(Info).Visit(const_cast<Expr*>(E));    return Result.isLValue();  } @@ -872,13 +871,13 @@ private:  } // end anonymous namespace  static bool EvaluateIntegerOrLValue(const Expr* E, APValue &Result, EvalInfo &Info) { -  if (!E->getType()->isIntegralType()) -    return false; - +  assert(E->getType()->isIntegralType());    return IntExprEvaluator(Info, Result).Visit(const_cast<Expr*>(E));  }  static bool EvaluateInteger(const Expr* E, APSInt &Result, EvalInfo &Info) { +  assert(E->getType()->isIntegralType()); +    APValue Val;    if (!EvaluateIntegerOrLValue(E, Val, Info) || !Val.isInt())      return false; @@ -1656,6 +1655,7 @@ public:  } // end anonymous namespace  static bool EvaluateFloat(const Expr* E, APFloat& Result, EvalInfo &Info) { +  assert(E->getType()->isRealFloatingType());    return FloatExprEvaluator(Info, Result).Visit(const_cast<Expr*>(E));  } @@ -1977,6 +1977,7 @@ public:  } // end anonymous namespace  static bool EvaluateComplex(const Expr *E, APValue &Result, EvalInfo &Info) { +  assert(E->getType()->isAnyComplexType());    Result = ComplexExprEvaluator(Info).Visit(const_cast<Expr*>(E));    assert((!Result.isComplexFloat() ||            (&Result.getComplexFloatReal().getSemantics() ==  | 

