diff options
author | Douglas Gregor <dgregor@apple.com> | 2010-05-15 06:01:05 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2010-05-15 06:01:05 +0000 |
commit | 6fd1b1802f5e748d2e8dfabeb03b62c0d65340ab (patch) | |
tree | a4e9b7b4cdad61d7785a9661b734f8311a9539c3 /clang/lib/Frontend | |
parent | 6625c7028e5e8c301fdd6e9153c403970f1b8075 (diff) | |
download | bcm5719-llvm-6fd1b1802f5e748d2e8dfabeb03b62c0d65340ab.tar.gz bcm5719-llvm-6fd1b1802f5e748d2e8dfabeb03b62c0d65340ab.zip |
Implement semantic analysis and an AST representation for the named
return value optimization. Sema marks return statements with their
NRVO candidates (which may or may not end up using the NRVO), then, at
the end of a function body, computes and marks those variables that
can be allocated into the return slot.
I've checked this locally with some debugging statements (not
committed), but there won't be any tests until CodeGen comes along.
llvm-svn: 103865
Diffstat (limited to 'clang/lib/Frontend')
-rw-r--r-- | clang/lib/Frontend/PCHReaderDecl.cpp | 1 | ||||
-rw-r--r-- | clang/lib/Frontend/PCHReaderStmt.cpp | 1 | ||||
-rw-r--r-- | clang/lib/Frontend/PCHWriterDecl.cpp | 2 | ||||
-rw-r--r-- | clang/lib/Frontend/PCHWriterStmt.cpp | 1 |
4 files changed, 5 insertions, 0 deletions
diff --git a/clang/lib/Frontend/PCHReaderDecl.cpp b/clang/lib/Frontend/PCHReaderDecl.cpp index 3f91d0cafb7..49010bf0d6d 100644 --- a/clang/lib/Frontend/PCHReaderDecl.cpp +++ b/clang/lib/Frontend/PCHReaderDecl.cpp @@ -435,6 +435,7 @@ void PCHDeclReader::VisitVarDecl(VarDecl *VD) { VD->setCXXDirectInitializer(Record[Idx++]); VD->setDeclaredInCondition(Record[Idx++]); VD->setExceptionVariable(Record[Idx++]); + VD->setNRVOVariable(Record[Idx++]); VD->setPreviousDeclaration( cast_or_null<VarDecl>(Reader.GetDecl(Record[Idx++]))); if (Record[Idx++]) diff --git a/clang/lib/Frontend/PCHReaderStmt.cpp b/clang/lib/Frontend/PCHReaderStmt.cpp index 7595d03a15f..3931adbe8f2 100644 --- a/clang/lib/Frontend/PCHReaderStmt.cpp +++ b/clang/lib/Frontend/PCHReaderStmt.cpp @@ -291,6 +291,7 @@ unsigned PCHStmtReader::VisitReturnStmt(ReturnStmt *S) { VisitStmt(S); S->setRetValue(cast_or_null<Expr>(StmtStack.back())); S->setReturnLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); + S->setNRVOCandidate(cast_or_null<VarDecl>(Reader.GetDecl(Record[Idx++]))); return 1; } diff --git a/clang/lib/Frontend/PCHWriterDecl.cpp b/clang/lib/Frontend/PCHWriterDecl.cpp index 28a10ad6b0a..cc58e8ee465 100644 --- a/clang/lib/Frontend/PCHWriterDecl.cpp +++ b/clang/lib/Frontend/PCHWriterDecl.cpp @@ -415,6 +415,7 @@ void PCHDeclWriter::VisitVarDecl(VarDecl *D) { Record.push_back(D->hasCXXDirectInitializer()); Record.push_back(D->isDeclaredInCondition()); Record.push_back(D->isExceptionVariable()); + Record.push_back(D->isNRVOVariable()); Writer.AddDeclRef(D->getPreviousDeclaration(), Record); Record.push_back(D->getInit() ? 1 : 0); if (D->getInit()) @@ -683,6 +684,7 @@ void PCHWriter::WriteDeclsBlockAbbrevs() { Abv->Add(BitCodeAbbrevOp(0)); // hasCXXDirectInitializer Abv->Add(BitCodeAbbrevOp(0)); // isDeclaredInCondition Abv->Add(BitCodeAbbrevOp(0)); // isExceptionVariable + Abv->Add(BitCodeAbbrevOp(0)); // isNRVOVariable Abv->Add(BitCodeAbbrevOp(0)); // PrevDecl Abv->Add(BitCodeAbbrevOp(0)); // HasInit // ParmVarDecl diff --git a/clang/lib/Frontend/PCHWriterStmt.cpp b/clang/lib/Frontend/PCHWriterStmt.cpp index a7f73a17fa6..a9ee43527ce 100644 --- a/clang/lib/Frontend/PCHWriterStmt.cpp +++ b/clang/lib/Frontend/PCHWriterStmt.cpp @@ -275,6 +275,7 @@ void PCHStmtWriter::VisitReturnStmt(ReturnStmt *S) { VisitStmt(S); Writer.WriteSubStmt(S->getRetValue()); Writer.AddSourceLocation(S->getReturnLoc(), Record); + Writer.AddDeclRef(S->getNRVOCandidate(), Record); Code = pch::STMT_RETURN; } |