[cfe-commits] r39886 - in /cfe/trunk: AST/Expr.cpp include/clang/AST/Expr.h
Chris Lattner
sabre at nondot.org
Sun Jul 15 16:32:58 PDT 2007
Author: lattner
Date: Sun Jul 15 18:32:58 2007
New Revision: 39886
URL: http://llvm.org/viewvc/llvm-project?rev=39886&view=rev
Log:
set the correct width for a character literal when evaluating it as an i-c-e.
Modified:
cfe/trunk/AST/Expr.cpp
cfe/trunk/include/clang/AST/Expr.h
Modified: cfe/trunk/AST/Expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/AST/Expr.cpp?rev=39886&r1=39885&r2=39886&view=diff
==============================================================================
--- cfe/trunk/AST/Expr.cpp (original)
+++ cfe/trunk/AST/Expr.cpp Sun Jul 15 18:32:58 2007
@@ -12,6 +12,7 @@
//===----------------------------------------------------------------------===//
#include "clang/AST/Expr.h"
+#include "clang/AST/ASTContext.h"
#include "clang/AST/StmtVisitor.h"
#include "clang/Lex/IdentifierTable.h"
using namespace clang;
@@ -287,11 +288,13 @@
case IntegerLiteralClass:
Result = cast<IntegerLiteral>(this)->getValue();
break;
- case CharacterLiteralClass:
- // FIXME: This doesn't set the right width etc.
- Result.zextOrTrunc(32); // FIXME: NOT RIGHT IN GENERAL.
- Result = cast<CharacterLiteral>(this)->getValue();
+ case CharacterLiteralClass: {
+ const CharacterLiteral *CL = cast<CharacterLiteral>(this);
+ Result.zextOrTrunc(Ctx.getTypeSize(getType(), CL->getLoc()));
+ Result = CL->getValue();
+ Result.setIsSigned(getType()->isSignedIntegerType());
break;
+ }
case DeclRefExprClass:
if (const EnumConstantDecl *D =
dyn_cast<EnumConstantDecl>(cast<DeclRefExpr>(this)->getDecl())) {
Modified: cfe/trunk/include/clang/AST/Expr.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=39886&r1=39885&r2=39886&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Sun Jul 15 18:32:58 2007
@@ -161,6 +161,8 @@
CharacterLiteral(unsigned value, QualType type, SourceLocation l)
: Expr(CharacterLiteralClass, type), Value(value), Loc(l) {
}
+ SourceLocation getLoc() const { return Loc; }
+
virtual SourceRange getSourceRange() const { return SourceRange(Loc); }
unsigned getValue() const { return Value; }
More information about the cfe-commits
mailing list