summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/clang/AST/ASTConsumer.h4
-rw-r--r--include/clang/Frontend/MultiplexConsumer.h2
-rw-r--r--lib/AST/ASTConsumer.cpp4
-rw-r--r--lib/CodeGen/CodeGenAction.cpp4
-rw-r--r--lib/CodeGen/ModuleBuilder.cpp3
-rw-r--r--lib/Frontend/ASTConsumers.cpp3
-rw-r--r--lib/Frontend/ASTUnit.cpp6
-rw-r--r--lib/Frontend/MultiplexConsumer.cpp3
-rw-r--r--lib/Parse/ParseAST.cpp13
-rw-r--r--lib/Rewrite/RewriteObjC.cpp3
-rw-r--r--tools/libclang/Indexing.cpp7
11 files changed, 35 insertions, 17 deletions
diff --git a/include/clang/AST/ASTConsumer.h b/include/clang/AST/ASTConsumer.h
index c6cb71cc7c..c1cde7f3ce 100644
--- a/include/clang/AST/ASTConsumer.h
+++ b/include/clang/AST/ASTConsumer.h
@@ -48,7 +48,9 @@ public:
/// called by the parser to process every top-level Decl*. Note that D can be
/// the head of a chain of Decls (e.g. for `int a, b` the chain will have two
/// elements). Use Decl::getNextDeclarator() to walk the chain.
- virtual void HandleTopLevelDecl(DeclGroupRef D);
+ ///
+ /// \returns true to continue parsing, or false to abort parsing.
+ virtual bool HandleTopLevelDecl(DeclGroupRef D);
/// HandleInterestingDecl - Handle the specified interesting declaration. This
/// is called by the AST reader when deserializing things that might interest
diff --git a/include/clang/Frontend/MultiplexConsumer.h b/include/clang/Frontend/MultiplexConsumer.h
index 4242f01171..89972991d1 100644
--- a/include/clang/Frontend/MultiplexConsumer.h
+++ b/include/clang/Frontend/MultiplexConsumer.h
@@ -33,7 +33,7 @@ public:
// ASTConsumer
virtual void Initialize(ASTContext &Context);
- virtual void HandleTopLevelDecl(DeclGroupRef D);
+ virtual bool HandleTopLevelDecl(DeclGroupRef D);
virtual void HandleInterestingDecl(DeclGroupRef D);
virtual void HandleTranslationUnit(ASTContext &Ctx);
virtual void HandleTagDeclDefinition(TagDecl *D);
diff --git a/lib/AST/ASTConsumer.cpp b/lib/AST/ASTConsumer.cpp
index 062f1103e9..1672bc8aed 100644
--- a/lib/AST/ASTConsumer.cpp
+++ b/lib/AST/ASTConsumer.cpp
@@ -15,7 +15,9 @@
#include "clang/AST/DeclGroup.h"
using namespace clang;
-void ASTConsumer::HandleTopLevelDecl(DeclGroupRef D) {}
+bool ASTConsumer::HandleTopLevelDecl(DeclGroupRef D) {
+ return true;
+}
void ASTConsumer::HandleInterestingDecl(DeclGroupRef D) {
HandleTopLevelDecl(D);
diff --git a/lib/CodeGen/CodeGenAction.cpp b/lib/CodeGen/CodeGenAction.cpp
index db2bab9bf6..fb926e1e8e 100644
--- a/lib/CodeGen/CodeGenAction.cpp
+++ b/lib/CodeGen/CodeGenAction.cpp
@@ -86,7 +86,7 @@ namespace clang {
LLVMIRGeneration.stopTimer();
}
- virtual void HandleTopLevelDecl(DeclGroupRef D) {
+ virtual bool HandleTopLevelDecl(DeclGroupRef D) {
PrettyStackTraceDecl CrashInfo(*D.begin(), SourceLocation(),
Context->getSourceManager(),
"LLVM IR generation of declaration");
@@ -98,6 +98,8 @@ namespace clang {
if (llvm::TimePassesIsEnabled)
LLVMIRGeneration.stopTimer();
+
+ return true;
}
virtual void HandleTranslationUnit(ASTContext &C) {
diff --git a/lib/CodeGen/ModuleBuilder.cpp b/lib/CodeGen/ModuleBuilder.cpp
index 793ee9192e..30572ed9af 100644
--- a/lib/CodeGen/ModuleBuilder.cpp
+++ b/lib/CodeGen/ModuleBuilder.cpp
@@ -59,10 +59,11 @@ namespace {
*M, *TD, Diags));
}
- virtual void HandleTopLevelDecl(DeclGroupRef DG) {
+ virtual bool HandleTopLevelDecl(DeclGroupRef DG) {
// Make sure to emit all elements of a Decl.
for (DeclGroupRef::iterator I = DG.begin(), E = DG.end(); I != E; ++I)
Builder->EmitTopLevelDecl(*I);
+ return true;
}
/// HandleTagDeclDefinition - This callback is invoked each time a TagDecl
diff --git a/lib/Frontend/ASTConsumers.cpp b/lib/Frontend/ASTConsumers.cpp
index 54bb282728..390ae09497 100644
--- a/lib/Frontend/ASTConsumers.cpp
+++ b/lib/Frontend/ASTConsumers.cpp
@@ -66,9 +66,10 @@ namespace {
this->Context = &Context;
}
- virtual void HandleTopLevelDecl(DeclGroupRef D) {
+ virtual bool HandleTopLevelDecl(DeclGroupRef D) {
for (DeclGroupRef::iterator I = D.begin(), E = D.end(); I != E; ++I)
HandleTopLevelSingleDecl(*I);
+ return true;
}
void HandleTopLevelSingleDecl(Decl *D);
diff --git a/lib/Frontend/ASTUnit.cpp b/lib/Frontend/ASTUnit.cpp
index c59f2d16d2..6cd0784215 100644
--- a/lib/Frontend/ASTUnit.cpp
+++ b/lib/Frontend/ASTUnit.cpp
@@ -878,9 +878,10 @@ public:
}
}
- void HandleTopLevelDecl(DeclGroupRef D) {
+ bool HandleTopLevelDecl(DeclGroupRef D) {
for (DeclGroupRef::iterator it = D.begin(), ie = D.end(); it != ie; ++it)
handleTopLevelDecl(*it);
+ return true;
}
// We're not interested in "interesting" decls.
@@ -926,7 +927,7 @@ public:
Hash = 0;
}
- virtual void HandleTopLevelDecl(DeclGroupRef D) {
+ virtual bool HandleTopLevelDecl(DeclGroupRef D) {
for (DeclGroupRef::iterator it = D.begin(), ie = D.end(); it != ie; ++it) {
Decl *D = *it;
// FIXME: Currently ObjC method declarations are incorrectly being
@@ -938,6 +939,7 @@ public:
AddTopLevelDeclarationToHash(D, Hash);
TopLevelDecls.push_back(D);
}
+ return true;
}
virtual void HandleTranslationUnit(ASTContext &Ctx) {
diff --git a/lib/Frontend/MultiplexConsumer.cpp b/lib/Frontend/MultiplexConsumer.cpp
index 8e746f65a9..e7b886ccb6 100644
--- a/lib/Frontend/MultiplexConsumer.cpp
+++ b/lib/Frontend/MultiplexConsumer.cpp
@@ -183,9 +183,10 @@ void MultiplexConsumer::Initialize(ASTContext &Context) {
Consumers[i]->Initialize(Context);
}
-void MultiplexConsumer::HandleTopLevelDecl(DeclGroupRef D) {
+bool MultiplexConsumer::HandleTopLevelDecl(DeclGroupRef D) {
for (size_t i = 0, e = Consumers.size(); i != e; ++i)
Consumers[i]->HandleTopLevelDecl(D);
+ return true;
}
void MultiplexConsumer::HandleInterestingDecl(DeclGroupRef D) {
diff --git a/lib/Parse/ParseAST.cpp b/lib/Parse/ParseAST.cpp
index fdd7d0f151..a5c345afe2 100644
--- a/lib/Parse/ParseAST.cpp
+++ b/lib/Parse/ParseAST.cpp
@@ -79,15 +79,24 @@ void clang::ParseAST(Sema &S, bool PrintStats) {
if (ExternalASTSource *External = S.getASTContext().getExternalSource())
External->StartTranslationUnit(Consumer);
+ bool Abort = false;
Parser::DeclGroupPtrTy ADecl;
while (!P.ParseTopLevelDecl(ADecl)) { // Not end of file.
// If we got a null return and something *was* parsed, ignore it. This
// is due to a top-level semicolon, an action override, or a parse error
// skipping something.
- if (ADecl)
- Consumer->HandleTopLevelDecl(ADecl.get());
+ if (ADecl) {
+ if (!Consumer->HandleTopLevelDecl(ADecl.get())) {
+ Abort = true;
+ break;
+ }
+ }
};
+
+ if (Abort)
+ return;
+
// Check for any pending objective-c implementation decl.
while ((ADecl = P.FinishPendingObjCActions()))
Consumer->HandleTopLevelDecl(ADecl.get());
diff --git a/lib/Rewrite/RewriteObjC.cpp b/lib/Rewrite/RewriteObjC.cpp
index 372e750132..f02e77e92b 100644
--- a/lib/Rewrite/RewriteObjC.cpp
+++ b/lib/Rewrite/RewriteObjC.cpp
@@ -167,7 +167,7 @@ namespace {
virtual void Initialize(ASTContext &context);
// Top Level Driver code.
- virtual void HandleTopLevelDecl(DeclGroupRef D) {
+ virtual bool HandleTopLevelDecl(DeclGroupRef D) {
for (DeclGroupRef::iterator I = D.begin(), E = D.end(); I != E; ++I) {
if (isa<ObjCClassDecl>((*I))) {
RewriteForwardClassDecl(D);
@@ -175,6 +175,7 @@ namespace {
}
HandleTopLevelSingleDecl(*I);
}
+ return true;
}
void HandleTopLevelSingleDecl(Decl *D);
void HandleDeclInMainFile(Decl *D);
diff --git a/tools/libclang/Indexing.cpp b/tools/libclang/Indexing.cpp
index 5858faad2e..3fa5a20ffc 100644
--- a/tools/libclang/Indexing.cpp
+++ b/tools/libclang/Indexing.cpp
@@ -115,12 +115,9 @@ public:
virtual void HandleTranslationUnit(ASTContext &Ctx) {
}
- virtual void HandleTopLevelDecl(DeclGroupRef DG) {
+ virtual bool HandleTopLevelDecl(DeclGroupRef DG) {
IndexCtx.indexDeclGroupRef(DG);
- // FIXME: Indicate to parser to abort.
-// if (IndexCtx.shouldAbort()) {
-//
-// }
+ return !IndexCtx.shouldAbort();
}
/// \brief Handle the specified top-level declaration that occurred inside