Fix bugs in isIntegerConstantExpr handling character and enum literals

llvm-svn: 39617
This commit is contained in:
Chris Lattner 2007-06-08 21:51:02 +00:00
parent 344b92e993
commit 4cd73fd380
2 changed files with 4 additions and 2 deletions

View File

@ -221,7 +221,7 @@ bool Expr::isIntegerConstantExpr(APSInt &Result, SourceLocation *Loc,
case CharacterLiteralClass:
// FIXME: This doesn't set the right width etc.
Result.zextOrTrunc(32); // FIXME: NOT RIGHT IN GENERAL.
Result = cast<IntegerLiteral>(this)->getValue();
Result = cast<CharacterLiteral>(this)->getValue();
break;
case DeclRefExprClass:
if (const EnumConstantDecl *D =
@ -229,7 +229,7 @@ bool Expr::isIntegerConstantExpr(APSInt &Result, SourceLocation *Loc,
D = D;
// FIXME: Get the real assigned value and width.
Result.zextOrTrunc(32); // FIXME: NOT RIGHT IN GENERAL.
Result = cast<IntegerLiteral>(this)->getValue();
Result = 0;
break;
}
if (Loc) *Loc = getLocStart();

View File

@ -151,6 +151,8 @@ public:
: Expr(CharacterLiteralClass, type), Value(value), Loc(l) {
}
virtual SourceRange getSourceRange() const { return SourceRange(Loc); }
unsigned getValue() const { return Value; }
virtual void visit(StmtVisitor &Visitor);
static bool classof(const Stmt *T) {