set the correct width for a character literal when evaluating it as an i-c-e.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39886 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/AST/Expr.cpp b/AST/Expr.cpp
index f7bf8e5..23c67e5 100644
--- a/AST/Expr.cpp
+++ b/AST/Expr.cpp
@@ -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())) {