[cfe-commits] r69106 - in /cfe/trunk: include/clang/AST/Expr.h include/clang/Frontend/PCHBitCodes.h lib/Frontend/PCHReader.cpp lib/Frontend/PCHWriter.cpp test/PCH/exprs.h

Douglas Gregor dgregor at apple.com
Tue Apr 14 16:59:38 PDT 2009


Author: dgregor
Date: Tue Apr 14 18:59:37 2009
New Revision: 69106

URL: http://llvm.org/viewvc/llvm-project?rev=69106&view=rev
Log:
PCH support for ParenExpr

Modified:
    cfe/trunk/include/clang/AST/Expr.h
    cfe/trunk/include/clang/Frontend/PCHBitCodes.h
    cfe/trunk/lib/Frontend/PCHReader.cpp
    cfe/trunk/lib/Frontend/PCHWriter.cpp
    cfe/trunk/test/PCH/exprs.h

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

==============================================================================
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Tue Apr 14 18:59:37 2009
@@ -628,15 +628,23 @@
            val->isTypeDependent(), val->isValueDependent()), 
       L(l), R(r), Val(val) {}
   
+  /// \brief Construct an empty parenthesized expression.
+  explicit ParenExpr(EmptyShell Empty) 
+    : Expr(ParenExprClass, Empty) { }
+
   const Expr *getSubExpr() const { return cast<Expr>(Val); }
   Expr *getSubExpr() { return cast<Expr>(Val); }
+  void setSubExpr(Expr *E) { Val = E; }
+
   virtual SourceRange getSourceRange() const { return SourceRange(L, R); }
 
   /// \brief Get the location of the left parentheses '('.
   SourceLocation getLParen() const { return L; }
+  void setLParen(SourceLocation Loc) { L = Loc; }
 
   /// \brief Get the location of the right parentheses ')'.
   SourceLocation getRParen() const { return R; }
+  void setRParen(SourceLocation Loc) { R = Loc; }
 
   static bool classof(const Stmt *T) { 
     return T->getStmtClass() == ParenExprClass; 

Modified: cfe/trunk/include/clang/Frontend/PCHBitCodes.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/PCHBitCodes.h?rev=69106&r1=69105&r2=69106&view=diff

==============================================================================
--- cfe/trunk/include/clang/Frontend/PCHBitCodes.h (original)
+++ cfe/trunk/include/clang/Frontend/PCHBitCodes.h Tue Apr 14 18:59:37 2009
@@ -383,6 +383,8 @@
       EXPR_FLOATING_LITERAL,
       /// \brief A CharacterLiteral record.
       EXPR_CHARACTER_LITERAL,
+      /// \brief A ParenExpr record.
+      EXPR_PAREN,
       /// \brief An ImplicitCastExpr record.
       EXPR_IMPLICIT_CAST
     };

Modified: cfe/trunk/lib/Frontend/PCHReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHReader.cpp?rev=69106&r1=69105&r2=69106&view=diff

==============================================================================
--- cfe/trunk/lib/Frontend/PCHReader.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHReader.cpp Tue Apr 14 18:59:37 2009
@@ -237,6 +237,7 @@
     unsigned VisitIntegerLiteral(IntegerLiteral *E);
     unsigned VisitFloatingLiteral(FloatingLiteral *E);
     unsigned VisitCharacterLiteral(CharacterLiteral *E);
+    unsigned VisitParenExpr(ParenExpr *E);
     unsigned VisitCastExpr(CastExpr *E);
     unsigned VisitImplicitCastExpr(ImplicitCastExpr *E);
   };
@@ -286,6 +287,14 @@
   return 0;
 }
 
+unsigned PCHStmtReader::VisitParenExpr(ParenExpr *E) {
+  VisitExpr(E);
+  E->setLParen(SourceLocation::getFromRawEncoding(Record[Idx++]));
+  E->setRParen(SourceLocation::getFromRawEncoding(Record[Idx++]));
+  E->setSubExpr(ExprStack.back());
+  return 1;
+}
+
 unsigned PCHStmtReader::VisitCastExpr(CastExpr *E) {
   VisitExpr(E);
   E->setSubExpr(ExprStack.back());
@@ -1605,6 +1614,10 @@
       E = new (Context) CharacterLiteral(Empty);
       break;
 
+    case pch::EXPR_PAREN:
+      E = new (Context) ParenExpr(Empty);
+      break;
+
     case pch::EXPR_IMPLICIT_CAST:
       E = new (Context) ImplicitCastExpr(Empty);
       break;

Modified: cfe/trunk/lib/Frontend/PCHWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHWriter.cpp?rev=69106&r1=69105&r2=69106&view=diff

==============================================================================
--- cfe/trunk/lib/Frontend/PCHWriter.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHWriter.cpp Tue Apr 14 18:59:37 2009
@@ -449,6 +449,7 @@
     void VisitIntegerLiteral(IntegerLiteral *E);
     void VisitFloatingLiteral(FloatingLiteral *E);
     void VisitCharacterLiteral(CharacterLiteral *E);
+    void VisitParenExpr(ParenExpr *E);
     void VisitCastExpr(CastExpr *E);
     void VisitImplicitCastExpr(ImplicitCastExpr *E);
   };
@@ -497,6 +498,14 @@
   Code = pch::EXPR_CHARACTER_LITERAL;
 }
 
+void PCHStmtWriter::VisitParenExpr(ParenExpr *E) {
+  VisitExpr(E);
+  Writer.AddSourceLocation(E->getLParen(), Record);
+  Writer.AddSourceLocation(E->getRParen(), Record);
+  Writer.WriteSubExpr(E->getSubExpr());
+  Code = pch::EXPR_PAREN;
+}
+
 void PCHStmtWriter::VisitCastExpr(CastExpr *E) {
   VisitExpr(E);
   Writer.WriteSubExpr(E->getSubExpr());

Modified: cfe/trunk/test/PCH/exprs.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/exprs.h?rev=69106&r1=69105&r2=69106&view=diff

==============================================================================
--- cfe/trunk/test/PCH/exprs.h (original)
+++ cfe/trunk/test/PCH/exprs.h Tue Apr 14 18:59:37 2009
@@ -11,7 +11,7 @@
 typedef typeof(17l) long_literal;
 
 // FloatingLiteral
-typedef typeof(42.5) floating_literal;
+typedef typeof((42.5)) floating_literal;
 
 // CharacterLiteral
 typedef typeof('a') char_literal;





More information about the cfe-commits mailing list