FunctionDecl::getBody() is getting an ASTContext argument for use in
lazy PCH deserialization. Propagate that argument wherever it needs to
be. No functionality change, except that I've tightened up a few PCH
tests in preparation.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69406 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/tools/clang-cc/ASTConsumers.cpp b/tools/clang-cc/ASTConsumers.cpp
index 61a9e44..aabbf2a 100644
--- a/tools/clang-cc/ASTConsumers.cpp
+++ b/tools/clang-cc/ASTConsumers.cpp
@@ -80,9 +80,10 @@
if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
PrintFunctionDeclStart(FD);
- if (FD->getBody()) {
+ // FIXME: Pass a context here so we can use getBody()
+ if (FD->getBodyIfAvailable()) {
Out << ' ';
- FD->getBody()->printPretty(Out, 0, Indentation, true);
+ FD->getBodyIfAvailable()->printPretty(Out, 0, Indentation, true);
Out << '\n';
}
} else if (isa<ObjCMethodDecl>(D)) {
@@ -221,7 +222,8 @@
}
void DeclPrinter::PrintFunctionDeclStart(FunctionDecl *FD) {
- bool HasBody = FD->getBody();
+ // FIXME: pass a context so that we can use getBody.
+ bool HasBody = FD->getBodyIfAvailable();
Out << '\n';
@@ -264,7 +266,7 @@
AFT->getResultType().getAsStringInternal(Proto);
Out << Proto;
- if (!FD->getBody())
+ if (!FD->getBodyIfAvailable())
Out << ";\n";
// Doesn't print the body.
}
@@ -596,10 +598,10 @@
if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
PrintFunctionDeclStart(FD);
- if (FD->getBody()) {
+ if (FD->getBodyIfAvailable()) {
Out << '\n';
// FIXME: convert dumper to use std::ostream?
- FD->getBody()->dumpAll(*SM);
+ FD->getBodyIfAvailable()->dumpAll(*SM);
Out << '\n';
}
} else if (TypedefDecl *TD = dyn_cast<TypedefDecl>(D)) {
@@ -664,9 +666,9 @@
if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
DeclPrinter().PrintFunctionDeclStart(FD);
- if (FD->getBody()) {
+ if (FD->getBodyIfAvailable()) {
llvm::cerr << '\n';
- FD->getBody()->viewAST();
+ FD->getBodyIfAvailable()->viewAST();
llvm::cerr << '\n';
}
return;
diff --git a/tools/clang-cc/AnalysisConsumer.cpp b/tools/clang-cc/AnalysisConsumer.cpp
index c39b1bc..b1fb741 100644
--- a/tools/clang-cc/AnalysisConsumer.cpp
+++ b/tools/clang-cc/AnalysisConsumer.cpp
@@ -425,7 +425,7 @@
AnalyzeSpecificFunction != FD->getIdentifier()->getName())
break;
- Stmt* Body = FD->getBody();
+ Stmt* Body = FD->getBody(*Ctx);
if (Body) HandleCode(FD, Body, FunctionActions);
break;
}
diff --git a/tools/clang-cc/RewriteBlocks.cpp b/tools/clang-cc/RewriteBlocks.cpp
index f1f53e4..a9324e6 100644
--- a/tools/clang-cc/RewriteBlocks.cpp
+++ b/tools/clang-cc/RewriteBlocks.cpp
@@ -1092,7 +1092,7 @@
// definitions using the same code.
RewriteFunctionProtoType(FD->getType(), FD);
- if (CompoundStmt *Body = FD->getBody()) {
+ if (CompoundStmt *Body = FD->getBody(*Context)) {
CurFunctionDef = FD;
FD->setBody(cast_or_null<CompoundStmt>(RewriteFunctionBody(Body)));
// This synthesizes and inserts the block "impl" struct, invoke function,
@@ -1104,7 +1104,7 @@
}
if (ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(D)) {
RewriteMethodDecl(MD);
- if (Stmt *Body = MD->getBody()) {
+ if (Stmt *Body = MD->getBody(*Context)) {
CurMethodDef = MD;
RewriteFunctionBody(Body);
InsertBlockLiteralsWithinMethod(MD);
@@ -1116,7 +1116,7 @@
RewriteBlockPointerDecl(VD);
if (VD->getInit()) {
if (BlockExpr *CBE = dyn_cast<BlockExpr>(VD->getInit())) {
- RewriteFunctionBody(CBE->getBody());
+ RewriteFunctionBody(CBE->getBody(*Context));
// We've just rewritten the block body in place.
// Now we snarf the rewritten text and stash it away for later use.
diff --git a/tools/clang-cc/RewriteObjC.cpp b/tools/clang-cc/RewriteObjC.cpp
index 41f532b..46f8e7e 100644
--- a/tools/clang-cc/RewriteObjC.cpp
+++ b/tools/clang-cc/RewriteObjC.cpp
@@ -994,7 +994,7 @@
ObjCMethodDecl *OMD = *I;
RewriteObjCMethodDecl(OMD, ResultStr);
SourceLocation LocStart = OMD->getLocStart();
- SourceLocation LocEnd = OMD->getBody()->getLocStart();
+ SourceLocation LocEnd = OMD->getBody(*Context)->getLocStart();
const char *startBuf = SM->getCharacterData(LocStart);
const char *endBuf = SM->getCharacterData(LocEnd);
@@ -1009,7 +1009,7 @@
ObjCMethodDecl *OMD = *I;
RewriteObjCMethodDecl(OMD, ResultStr);
SourceLocation LocStart = OMD->getLocStart();
- SourceLocation LocEnd = OMD->getBody()->getLocStart();
+ SourceLocation LocEnd = OMD->getBody(*Context)->getLocStart();
const char *startBuf = SM->getCharacterData(LocStart);
const char *endBuf = SM->getCharacterData(LocEnd);
@@ -4445,7 +4445,7 @@
// definitions using the same code.
RewriteBlocksInFunctionProtoType(FD->getType(), FD);
- if (CompoundStmt *Body = FD->getBody()) {
+ if (CompoundStmt *Body = FD->getBody(*Context)) {
CurFunctionDef = FD;
CollectPropertySetters(Body);
CurrentBody = Body;