diff options
author | Eli Friedman <eli.friedman@gmail.com> | 2009-12-10 22:29:29 +0000 |
---|---|---|
committer | Eli Friedman <eli.friedman@gmail.com> | 2009-12-10 22:29:29 +0000 |
commit | ee275c82ffd451499595d753d0dc3576f5e2280f (patch) | |
tree | 523369107145862231b1e5cf208786e8604706aa /clang/lib/AST/ExprConstant.cpp | |
parent | 781161dc55edbbf5f95a9d6e52d1b9bd2348bdcb (diff) | |
download | bcm5719-llvm-ee275c82ffd451499595d753d0dc3576f5e2280f.tar.gz bcm5719-llvm-ee275c82ffd451499595d753d0dc3576f5e2280f.zip |
Clean up enum constants so that they're finally sane. Fixes PR3173 and a
recently introduced crash.
llvm-svn: 91070
Diffstat (limited to 'clang/lib/AST/ExprConstant.cpp')
-rw-r--r-- | clang/lib/AST/ExprConstant.cpp | 12 |
1 files changed, 2 insertions, 10 deletions
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp index 670753ca15f..ea30b193094 100644 --- a/clang/lib/AST/ExprConstant.cpp +++ b/clang/lib/AST/ExprConstant.cpp @@ -848,16 +848,8 @@ static bool EvaluateInteger(const Expr* E, APSInt &Result, EvalInfo &Info) { bool IntExprEvaluator::CheckReferencedDecl(const Expr* E, const Decl* D) { // Enums are integer constant exprs. - if (const EnumConstantDecl *ECD = dyn_cast<EnumConstantDecl>(D)) { - // FIXME: This is an ugly hack around the fact that enums don't set their - // signedness consistently; see PR3173. - APSInt SI = ECD->getInitVal(); - SI.setIsUnsigned(!E->getType()->isSignedIntegerType()); - // FIXME: This is an ugly hack around the fact that enums don't - // set their width (!?!) consistently; see PR3173. - SI.extOrTrunc(Info.Ctx.getIntWidth(E->getType())); - return Success(SI, E); - } + if (const EnumConstantDecl *ECD = dyn_cast<EnumConstantDecl>(D)) + return Success(ECD->getInitVal(), E); // In C++, const, non-volatile integers initialized with ICEs are ICEs. // In C, they can also be folded, although they are not ICEs. |