aboutsummaryrefslogtreecommitdiff
path: root/lib/Frontend
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-05-09 06:40:08 +0000
committerChris Lattner <sabre@nondot.org>2010-05-09 06:40:08 +0000
commit030854b95f7bfd86aaa8afd9ae1aff9768a37e9a (patch)
tree691c8cd1a296c9461e34eabc9b6c882410a33022 /lib/Frontend
parent2fbdfcdf3bbf7b941853d38b123930755e837437 (diff)
pch'ify default argument definitions and uses.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103376 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Frontend')
-rw-r--r--lib/Frontend/PCHReaderStmt.cpp17
-rw-r--r--lib/Frontend/PCHWriterDecl.cpp6
-rw-r--r--lib/Frontend/PCHWriterStmt.cpp15
3 files changed, 34 insertions, 4 deletions
diff --git a/lib/Frontend/PCHReaderStmt.cpp b/lib/Frontend/PCHReaderStmt.cpp
index c3cc504a1a..3392c04d55 100644
--- a/lib/Frontend/PCHReaderStmt.cpp
+++ b/lib/Frontend/PCHReaderStmt.cpp
@@ -129,6 +129,7 @@ namespace {
unsigned VisitCXXTypeidExpr(CXXTypeidExpr *E);
unsigned VisitCXXThisExpr(CXXThisExpr *E);
unsigned VisitCXXThrowExpr(CXXThrowExpr *E);
+ unsigned VisitCXXDefaultArgExpr(CXXDefaultArgExpr *E);
};
}
@@ -532,7 +533,6 @@ unsigned PCHStmtReader::VisitCastExpr(CastExpr *E) {
VisitExpr(E);
E->setSubExpr(cast<Expr>(StmtStack.back()));
E->setCastKind((CastExpr::CastKind)Record[Idx++]);
-
return 1;
}
@@ -1004,6 +1004,7 @@ unsigned PCHStmtReader::VisitCXXTypeidExpr(CXXTypeidExpr *E) {
}
// typeid(42+2)
+ E->setExprOperand(cast<Expr>(StmtStack.back()));
return 1;
}
@@ -1017,9 +1018,20 @@ unsigned PCHStmtReader::VisitCXXThisExpr(CXXThisExpr *E) {
unsigned PCHStmtReader::VisitCXXThrowExpr(CXXThrowExpr *E) {
VisitExpr(E);
E->setThrowLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
+ E->setSubExpr(cast<Expr>(StmtStack.back()));
return 1;
}
+unsigned PCHStmtReader::VisitCXXDefaultArgExpr(CXXDefaultArgExpr *E) {
+ VisitExpr(E);
+ E->setUsedLocation(SourceLocation::getFromRawEncoding(Record[Idx++]));
+ bool HasStoredExpr = Record[Idx++];
+ if (!HasStoredExpr) return 0;
+ E->setExpr(cast<Expr>(StmtStack.back()));
+ return 1; // Read it.
+}
+
+
// Within the bitstream, expressions are stored in Reverse Polish
// Notation, with each of the subexpressions preceding the
// expression they are stored in. To evaluate expressions, we
@@ -1381,6 +1393,9 @@ Stmt *PCHReader::ReadStmt(llvm::BitstreamCursor &Cursor) {
case pch::EXPR_CXX_THROW:
S = new (Context) CXXThrowExpr(Empty);
break;
+ case pch::EXPR_CXX_DEFAULT_ARG:
+ S = new (Context) CXXDefaultArgExpr(Empty);
+ break;
}
// We hit a STMT_STOP, so we're done with this expression.
diff --git a/lib/Frontend/PCHWriterDecl.cpp b/lib/Frontend/PCHWriterDecl.cpp
index a898c705e2..28a10ad6b0 100644
--- a/lib/Frontend/PCHWriterDecl.cpp
+++ b/lib/Frontend/PCHWriterDecl.cpp
@@ -416,7 +416,7 @@ void PCHDeclWriter::VisitVarDecl(VarDecl *D) {
Record.push_back(D->isDeclaredInCondition());
Record.push_back(D->isExceptionVariable());
Writer.AddDeclRef(D->getPreviousDeclaration(), Record);
- Record.push_back(D->getInit()? 1 : 0);
+ Record.push_back(D->getInit() ? 1 : 0);
if (D->getInit())
Writer.AddStmt(D->getInit());
Code = pch::DECL_VAR;
@@ -445,7 +445,8 @@ void PCHDeclWriter::VisitParmVarDecl(ParmVarDecl *D) {
D->getStorageClass() == 0 &&
!D->hasCXXDirectInitializer() && // Can params have this ever?
D->getObjCDeclQualifier() == 0 &&
- !D->hasInheritedDefaultArg())
+ !D->hasInheritedDefaultArg() &&
+ D->getInit() == 0) // No default expr.
AbbrevToUse = Writer.getParmVarDeclAbbrev();
// Check things we know are true of *every* PARM_VAR_DECL, which is more than
@@ -456,7 +457,6 @@ void PCHDeclWriter::VisitParmVarDecl(ParmVarDecl *D) {
assert(!D->isDeclaredInCondition() && "PARM_VAR_DECL can't be in condition");
assert(!D->isExceptionVariable() && "PARM_VAR_DECL can't be exception var");
assert(D->getPreviousDeclaration() == 0 && "PARM_VAR_DECL can't be redecl");
- assert(D->getInit() == 0 && "PARM_VAR_DECL never has init");
}
void PCHDeclWriter::VisitFileScopeAsmDecl(FileScopeAsmDecl *D) {
diff --git a/lib/Frontend/PCHWriterStmt.cpp b/lib/Frontend/PCHWriterStmt.cpp
index e042e77c6b..e64ebbe8a3 100644
--- a/lib/Frontend/PCHWriterStmt.cpp
+++ b/lib/Frontend/PCHWriterStmt.cpp
@@ -125,6 +125,7 @@ namespace {
void VisitCXXTypeidExpr(CXXTypeidExpr *E);
void VisitCXXThisExpr(CXXThisExpr *E);
void VisitCXXThrowExpr(CXXThrowExpr *E);
+ void VisitCXXDefaultArgExpr(CXXDefaultArgExpr *E);
};
}
@@ -934,11 +935,25 @@ void PCHStmtWriter::VisitCXXThisExpr(CXXThisExpr *E) {
}
void PCHStmtWriter::VisitCXXThrowExpr(CXXThrowExpr *E) {
+ VisitExpr(E);
Writer.AddSourceLocation(E->getThrowLoc(), Record);
Writer.WriteSubStmt(E->getSubExpr());
Code = pch::EXPR_CXX_THROW;
}
+void PCHStmtWriter::VisitCXXDefaultArgExpr(CXXDefaultArgExpr *E) {
+ VisitExpr(E);
+ Writer.AddSourceLocation(E->getUsedLocation(), Record);
+ if (E->isExprStored()) {
+ Record.push_back(1);
+ Writer.WriteSubStmt(E->getExpr());
+ } else {
+ Record.push_back(0);
+ }
+
+ Code = pch::EXPR_CXX_DEFAULT_ARG;
+}
+
//===----------------------------------------------------------------------===//
// PCHWriter Implementation