зеркало из https://github.com/microsoft/clang-1.git
Read/write CXXDeleteExpr from/to PCH.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106552 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
7c5b1097f5
Коммит
95fc98ce95
|
@ -1082,18 +1082,26 @@ public:
|
|||
: 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;
|
||||
|
|
|
@ -763,6 +763,7 @@ namespace clang {
|
|||
//
|
||||
EXPR_CXX_ZERO_INIT_VALUE, // CXXZeroInitValueExpr
|
||||
EXPR_CXX_NEW, // CXXNewExpr
|
||||
EXPR_CXX_DELETE, // CXXDeleteExpr
|
||||
|
||||
EXPR_CXX_EXPR_WITH_TEMPORARIES // CXXExprWithTemporaries
|
||||
};
|
||||
|
|
|
@ -134,6 +134,7 @@ namespace {
|
|||
|
||||
unsigned VisitCXXZeroInitValueExpr(CXXZeroInitValueExpr *E);
|
||||
unsigned VisitCXXNewExpr(CXXNewExpr *E);
|
||||
unsigned VisitCXXDeleteExpr(CXXDeleteExpr *E);
|
||||
|
||||
unsigned VisitCXXExprWithTemporaries(CXXExprWithTemporaries *E);
|
||||
};
|
||||
|
@ -1087,6 +1088,16 @@ unsigned PCHStmtReader::VisitCXXNewExpr(CXXNewExpr *E) {
|
|||
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 @@ Stmt *PCHReader::ReadStmt(llvm::BitstreamCursor &Cursor) {
|
|||
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:
|
||||
|
|
|
@ -130,6 +130,7 @@ namespace {
|
|||
|
||||
void VisitCXXZeroInitValueExpr(CXXZeroInitValueExpr *E);
|
||||
void VisitCXXNewExpr(CXXNewExpr *E);
|
||||
void VisitCXXDeleteExpr(CXXDeleteExpr *E);
|
||||
|
||||
void VisitCXXExprWithTemporaries(CXXExprWithTemporaries *E);
|
||||
};
|
||||
|
@ -997,6 +998,16 @@ void PCHStmtWriter::VisitCXXNewExpr(CXXNewExpr *E) {
|
|||
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);
|
||||
|
|
|
@ -68,8 +68,8 @@ void Derived::g() {
|
|||
int A = int(0.5); // CXXFunctionalCastExpr
|
||||
A = int(); // CXXZeroInitValueExpr
|
||||
|
||||
new Base(4); // CXXNewExpr
|
||||
|
||||
Base *b = new Base(4); // CXXNewExpr
|
||||
delete b; // CXXDeleteExpr
|
||||
}
|
||||
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче