diff options
-rw-r--r-- | clang/include/clang/AST/Expr.h | 6 | ||||
-rw-r--r-- | clang/lib/AST/StmtPrinter.cpp | 3 | ||||
-rw-r--r-- | clang/lib/AST/StmtSerialization.cpp | 4 | ||||
-rw-r--r-- | clang/lib/Sema/SemaExpr.cpp | 3 |
4 files changed, 11 insertions, 5 deletions
diff --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h index 9a76823ff26..42344d0feac 100644 --- a/clang/include/clang/AST/Expr.h +++ b/clang/include/clang/AST/Expr.h @@ -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); } diff --git a/clang/lib/AST/StmtPrinter.cpp b/clang/lib/AST/StmtPrinter.cpp index 5e347435b63..dc686f9bf59 100644 --- a/clang/lib/AST/StmtPrinter.cpp +++ b/clang/lib/AST/StmtPrinter.cpp @@ -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 << "'\\\\'"; diff --git a/clang/lib/AST/StmtSerialization.cpp b/clang/lib/AST/StmtSerialization.cpp index 99a890946de..6fcc1ef4282 100644 --- a/clang/lib/AST/StmtSerialization.cpp +++ b/clang/lib/AST/StmtSerialization.cpp @@ -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 { diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index e918572f35f..e84971062ed 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -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) { |