]> granicus.if.org Git - clang/commitdiff
capture whether a CharacterLiteral was wide or not in the AST.
authorChris Lattner <sabre@nondot.org>
Sat, 7 Jun 2008 22:35:38 +0000 (22:35 +0000)
committerChris Lattner <sabre@nondot.org>
Sat, 7 Jun 2008 22:35:38 +0000 (22:35 +0000)
Patch by Mike Stump!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@52081 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/Expr.h
lib/AST/StmtPrinter.cpp
lib/AST/StmtSerialization.cpp
lib/Sema/SemaExpr.cpp

index 9a76823ff263f83c8b0af4fb0503b4f45ed5604e..42344d0feac6bb28f11f7d967afb0b09d6c3b751 100644 (file)
@@ -234,12 +234,14 @@ public:
 class CharacterLiteral : public Expr {
   unsigned Value;
   SourceLocation Loc;
+  bool IsWide;
 public:
   // type should be IntTy
-  CharacterLiteral(unsigned value, QualType type, SourceLocation l)
-    : Expr(CharacterLiteralClass, type), Value(value), Loc(l) {
+  CharacterLiteral(unsigned value, bool iswide, QualType type, SourceLocation l)
+    : Expr(CharacterLiteralClass, type), Value(value), Loc(l), IsWide(iswide) {
   }
   SourceLocation getLoc() const { return Loc; }
+  bool isWide() const { return IsWide; }
   
   virtual SourceRange getSourceRange() const { return SourceRange(Loc); }
   
index 5e347435b6339122256547245ea7f416cf2912f0..dc686f9bf59688d2b03624147ac66fc91dcf23d6 100644 (file)
@@ -513,8 +513,9 @@ void StmtPrinter::VisitPreDefinedExpr(PreDefinedExpr *Node) {
 }
 
 void StmtPrinter::VisitCharacterLiteral(CharacterLiteral *Node) {
-  // FIXME should print an L for wchar_t constants
   unsigned value = Node->getValue();
+  if (Node->isWide())
+    OS << "L";
   switch (value) {
   case '\\':
     OS << "'\\\\'";
index 99a890946de09f8bd18434e6f97be85e762bf371..6fcc1ef42823a99f67febfafd9b5dced8f6b45f8 100644 (file)
@@ -375,14 +375,16 @@ CastExpr* CastExpr::CreateImpl(Deserializer& D, ASTContext& C) {
 void CharacterLiteral::EmitImpl(Serializer& S) const {
   S.Emit(Value);
   S.Emit(Loc);
+  S.EmitBool(IsWide);
   S.Emit(getType());
 }
 
 CharacterLiteral* CharacterLiteral::CreateImpl(Deserializer& D, ASTContext& C) {
   unsigned value = D.ReadInt();
   SourceLocation Loc = SourceLocation::ReadVal(D);
+  bool iswide = D.ReadBool();
   QualType T = QualType::ReadVal(D);
-  return new CharacterLiteral(value,T,Loc);
+  return new CharacterLiteral(value,iswide,T,Loc);
 }
 
 void CompoundAssignOperator::EmitImpl(Serializer& S) const {
index e918572f35f243ce8818416649c5962aebe19660..e84971062eda6742a0986aa5c7b944104574f61d 100644 (file)
@@ -183,7 +183,8 @@ Sema::ExprResult Sema::ActOnCharacterConstant(const Token &Tok) {
 
   QualType type = getLangOptions().CPlusPlus ? Context.CharTy : Context.IntTy;
 
-  return new CharacterLiteral(Literal.getValue(), type, Tok.getLocation());
+  return new CharacterLiteral(Literal.getValue(), Literal.isWide(), type,
+                              Tok.getLocation());
 }
 
 Action::ExprResult Sema::ActOnNumericConstant(const Token &Tok) {