[cfe-commits] r52081 - in /cfe/trunk: include/clang/AST/Expr.h lib/AST/StmtPrinter.cpp lib/AST/StmtSerialization.cpp lib/Sema/SemaExpr.cpp

Chris Lattner sabre at nondot.org
Sat Jun 7 15:35:39 PDT 2008


Author: lattner
Date: Sat Jun  7 17:35:38 2008
New Revision: 52081

URL: http://llvm.org/viewvc/llvm-project?rev=52081&view=rev
Log:
capture whether a CharacterLiteral was wide or not in the AST. 
Patch by Mike Stump!

Modified:
    cfe/trunk/include/clang/AST/Expr.h
    cfe/trunk/lib/AST/StmtPrinter.cpp
    cfe/trunk/lib/AST/StmtSerialization.cpp
    cfe/trunk/lib/Sema/SemaExpr.cpp

Modified: cfe/trunk/include/clang/AST/Expr.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=52081&r1=52080&r2=52081&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Sat Jun  7 17:35:38 2008
@@ -234,12 +234,14 @@
 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); }
   

Modified: cfe/trunk/lib/AST/StmtPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtPrinter.cpp?rev=52081&r1=52080&r2=52081&view=diff

==============================================================================
--- cfe/trunk/lib/AST/StmtPrinter.cpp (original)
+++ cfe/trunk/lib/AST/StmtPrinter.cpp Sat Jun  7 17:35:38 2008
@@ -513,8 +513,9 @@
 }
 
 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 << "'\\\\'";

Modified: cfe/trunk/lib/AST/StmtSerialization.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtSerialization.cpp?rev=52081&r1=52080&r2=52081&view=diff

==============================================================================
--- cfe/trunk/lib/AST/StmtSerialization.cpp (original)
+++ cfe/trunk/lib/AST/StmtSerialization.cpp Sat Jun  7 17:35:38 2008
@@ -375,14 +375,16 @@
 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 {

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=52081&r1=52080&r2=52081&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Sat Jun  7 17:35:38 2008
@@ -183,7 +183,8 @@
 
   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) {





More information about the cfe-commits mailing list