[cfe-commits] r106552 - in /cfe/trunk: include/clang/AST/ExprCXX.h include/clang/Frontend/PCHBitCodes.h lib/Frontend/PCHReaderStmt.cpp lib/Frontend/PCHWriterStmt.cpp test/PCH/cxx_exprs.h
Argyrios Kyrtzidis
akyrtzi at gmail.com
Tue Jun 22 10:07:59 PDT 2010
Author: akirtzidis
Date: Tue Jun 22 12:07:59 2010
New Revision: 106552
URL: http://llvm.org/viewvc/llvm-project?rev=106552&view=rev
Log:
Read/write CXXDeleteExpr from/to PCH.
Modified:
cfe/trunk/include/clang/AST/ExprCXX.h
cfe/trunk/include/clang/Frontend/PCHBitCodes.h
cfe/trunk/lib/Frontend/PCHReaderStmt.cpp
cfe/trunk/lib/Frontend/PCHWriterStmt.cpp
cfe/trunk/test/PCH/cxx_exprs.h
Modified: cfe/trunk/include/clang/AST/ExprCXX.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExprCXX.h?rev=106552&r1=106551&r2=106552&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/ExprCXX.h (original)
+++ cfe/trunk/include/clang/AST/ExprCXX.h Tue Jun 22 12:07:59 2010
@@ -1082,18 +1082,26 @@
: Expr(CXXDeleteExprClass, ty, false, false), GlobalDelete(globalDelete),
ArrayForm(arrayForm), OperatorDelete(operatorDelete), Argument(arg),
Loc(loc) { }
+ explicit CXXDeleteExpr(EmptyShell Shell)
+ : Expr(CXXDeleteExprClass, Shell), OperatorDelete(0), Argument(0) { }
bool isGlobalDelete() const { return GlobalDelete; }
bool isArrayForm() const { return ArrayForm; }
+
+ void setGlobalDelete(bool V) { GlobalDelete = V; }
+ void setArrayForm(bool V) { ArrayForm = V; }
FunctionDecl *getOperatorDelete() const { return OperatorDelete; }
+ void setOperatorDelete(FunctionDecl *D) { OperatorDelete = D; }
Expr *getArgument() { return cast<Expr>(Argument); }
const Expr *getArgument() const { return cast<Expr>(Argument); }
+ void setArgument(Expr *E) { Argument = E; }
virtual SourceRange getSourceRange() const {
return SourceRange(Loc, Argument->getLocEnd());
}
+ void setStartLoc(SourceLocation L) { Loc = L; }
static bool classof(const Stmt *T) {
return T->getStmtClass() == CXXDeleteExprClass;
Modified: cfe/trunk/include/clang/Frontend/PCHBitCodes.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/PCHBitCodes.h?rev=106552&r1=106551&r2=106552&view=diff
==============================================================================
--- cfe/trunk/include/clang/Frontend/PCHBitCodes.h (original)
+++ cfe/trunk/include/clang/Frontend/PCHBitCodes.h Tue Jun 22 12:07:59 2010
@@ -763,6 +763,7 @@
//
EXPR_CXX_ZERO_INIT_VALUE, // CXXZeroInitValueExpr
EXPR_CXX_NEW, // CXXNewExpr
+ EXPR_CXX_DELETE, // CXXDeleteExpr
EXPR_CXX_EXPR_WITH_TEMPORARIES // CXXExprWithTemporaries
};
Modified: cfe/trunk/lib/Frontend/PCHReaderStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHReaderStmt.cpp?rev=106552&r1=106551&r2=106552&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/PCHReaderStmt.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHReaderStmt.cpp Tue Jun 22 12:07:59 2010
@@ -134,6 +134,7 @@
unsigned VisitCXXZeroInitValueExpr(CXXZeroInitValueExpr *E);
unsigned VisitCXXNewExpr(CXXNewExpr *E);
+ unsigned VisitCXXDeleteExpr(CXXDeleteExpr *E);
unsigned VisitCXXExprWithTemporaries(CXXExprWithTemporaries *E);
};
@@ -1087,6 +1088,16 @@
return TotalSubExprs;
}
+unsigned PCHStmtReader::VisitCXXDeleteExpr(CXXDeleteExpr *E) {
+ VisitExpr(E);
+ E->setGlobalDelete(Record[Idx++]);
+ E->setArrayForm(Record[Idx++]);
+ E->setOperatorDelete(
+ cast_or_null<FunctionDecl>(Reader.GetDecl(Record[Idx++])));
+ E->setArgument(cast_or_null<Expr>(StmtStack.back()));
+ E->setStartLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
+ return 1;
+}
unsigned PCHStmtReader::VisitCXXExprWithTemporaries(CXXExprWithTemporaries *E) {
VisitExpr(E);
@@ -1475,6 +1486,9 @@
case pch::EXPR_CXX_NEW:
S = new (Context) CXXNewExpr(Empty);
break;
+ case pch::EXPR_CXX_DELETE:
+ S = new (Context) CXXDeleteExpr(Empty);
+ break;
case pch::EXPR_CXX_EXPR_WITH_TEMPORARIES:
Modified: cfe/trunk/lib/Frontend/PCHWriterStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHWriterStmt.cpp?rev=106552&r1=106551&r2=106552&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/PCHWriterStmt.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHWriterStmt.cpp Tue Jun 22 12:07:59 2010
@@ -130,6 +130,7 @@
void VisitCXXZeroInitValueExpr(CXXZeroInitValueExpr *E);
void VisitCXXNewExpr(CXXNewExpr *E);
+ void VisitCXXDeleteExpr(CXXDeleteExpr *E);
void VisitCXXExprWithTemporaries(CXXExprWithTemporaries *E);
};
@@ -997,6 +998,16 @@
Code = pch::EXPR_CXX_NEW;
}
+void PCHStmtWriter::VisitCXXDeleteExpr(CXXDeleteExpr *E) {
+ VisitExpr(E);
+ Record.push_back(E->isGlobalDelete());
+ Record.push_back(E->isArrayForm());
+ Writer.AddDeclRef(E->getOperatorDelete(), Record);
+ Writer.WriteSubStmt(E->getArgument());
+ Writer.AddSourceLocation(E->getSourceRange().getBegin(), Record);
+
+ Code = pch::EXPR_CXX_DELETE;
+}
void PCHStmtWriter::VisitCXXExprWithTemporaries(CXXExprWithTemporaries *E) {
VisitExpr(E);
Modified: cfe/trunk/test/PCH/cxx_exprs.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/cxx_exprs.h?rev=106552&r1=106551&r2=106552&view=diff
==============================================================================
--- cfe/trunk/test/PCH/cxx_exprs.h (original)
+++ cfe/trunk/test/PCH/cxx_exprs.h Tue Jun 22 12:07:59 2010
@@ -68,8 +68,8 @@
int A = int(0.5); // CXXFunctionalCastExpr
A = int(); // CXXZeroInitValueExpr
- new Base(4); // CXXNewExpr
-
+ Base *b = new Base(4); // CXXNewExpr
+ delete b; // CXXDeleteExpr
}
More information about the cfe-commits
mailing list