[cfe-commits] r144943 - in /cfe/trunk: include/clang/AST/ASTConsumer.h include/clang/Frontend/MultiplexConsumer.h lib/AST/ASTConsumer.cpp lib/CodeGen/CodeGenAction.cpp lib/CodeGen/ModuleBuilder.cpp lib/Frontend/ASTConsumers.cpp lib/Frontend/ASTUnit.cpp lib/Frontend/MultiplexConsumer.cpp lib/Parse/ParseAST.cpp lib/Rewrite/RewriteObjC.cpp tools/libclang/Indexing.cpp
Argyrios Kyrtzidis
akyrtzi at gmail.com
Thu Nov 17 16:26:59 PST 2011
Author: akirtzidis
Date: Thu Nov 17 18:26:59 2011
New Revision: 144943
URL: http://llvm.org/viewvc/llvm-project?rev=144943&view=rev
Log:
Change ASTConsumer::HandleTopLevelDecl to return true for the parser to continue
parsing or false to abort parsing.
Modified:
cfe/trunk/include/clang/AST/ASTConsumer.h
cfe/trunk/include/clang/Frontend/MultiplexConsumer.h
cfe/trunk/lib/AST/ASTConsumer.cpp
cfe/trunk/lib/CodeGen/CodeGenAction.cpp
cfe/trunk/lib/CodeGen/ModuleBuilder.cpp
cfe/trunk/lib/Frontend/ASTConsumers.cpp
cfe/trunk/lib/Frontend/ASTUnit.cpp
cfe/trunk/lib/Frontend/MultiplexConsumer.cpp
cfe/trunk/lib/Parse/ParseAST.cpp
cfe/trunk/lib/Rewrite/RewriteObjC.cpp
cfe/trunk/tools/libclang/Indexing.cpp
Modified: cfe/trunk/include/clang/AST/ASTConsumer.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTConsumer.h?rev=144943&r1=144942&r2=144943&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/ASTConsumer.h (original)
+++ cfe/trunk/include/clang/AST/ASTConsumer.h Thu Nov 17 18:26:59 2011
@@ -48,7 +48,9 @@
/// 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
Modified: cfe/trunk/include/clang/Frontend/MultiplexConsumer.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/MultiplexConsumer.h?rev=144943&r1=144942&r2=144943&view=diff
==============================================================================
--- cfe/trunk/include/clang/Frontend/MultiplexConsumer.h (original)
+++ cfe/trunk/include/clang/Frontend/MultiplexConsumer.h Thu Nov 17 18:26:59 2011
@@ -33,7 +33,7 @@
// 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);
Modified: cfe/trunk/lib/AST/ASTConsumer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTConsumer.cpp?rev=144943&r1=144942&r2=144943&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTConsumer.cpp (original)
+++ cfe/trunk/lib/AST/ASTConsumer.cpp Thu Nov 17 18:26:59 2011
@@ -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);
Modified: cfe/trunk/lib/CodeGen/CodeGenAction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenAction.cpp?rev=144943&r1=144942&r2=144943&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenAction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenAction.cpp Thu Nov 17 18:26:59 2011
@@ -86,7 +86,7 @@
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 @@
if (llvm::TimePassesIsEnabled)
LLVMIRGeneration.stopTimer();
+
+ return true;
}
virtual void HandleTranslationUnit(ASTContext &C) {
Modified: cfe/trunk/lib/CodeGen/ModuleBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ModuleBuilder.cpp?rev=144943&r1=144942&r2=144943&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/ModuleBuilder.cpp (original)
+++ cfe/trunk/lib/CodeGen/ModuleBuilder.cpp Thu Nov 17 18:26:59 2011
@@ -59,10 +59,11 @@
*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
Modified: cfe/trunk/lib/Frontend/ASTConsumers.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ASTConsumers.cpp?rev=144943&r1=144942&r2=144943&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/ASTConsumers.cpp (original)
+++ cfe/trunk/lib/Frontend/ASTConsumers.cpp Thu Nov 17 18:26:59 2011
@@ -66,9 +66,10 @@
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);
Modified: cfe/trunk/lib/Frontend/ASTUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ASTUnit.cpp?rev=144943&r1=144942&r2=144943&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/ASTUnit.cpp (original)
+++ cfe/trunk/lib/Frontend/ASTUnit.cpp Thu Nov 17 18:26:59 2011
@@ -878,9 +878,10 @@
}
}
- 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 @@
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 @@
AddTopLevelDeclarationToHash(D, Hash);
TopLevelDecls.push_back(D);
}
+ return true;
}
virtual void HandleTranslationUnit(ASTContext &Ctx) {
Modified: cfe/trunk/lib/Frontend/MultiplexConsumer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/MultiplexConsumer.cpp?rev=144943&r1=144942&r2=144943&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/MultiplexConsumer.cpp (original)
+++ cfe/trunk/lib/Frontend/MultiplexConsumer.cpp Thu Nov 17 18:26:59 2011
@@ -183,9 +183,10 @@
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) {
Modified: cfe/trunk/lib/Parse/ParseAST.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseAST.cpp?rev=144943&r1=144942&r2=144943&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseAST.cpp (original)
+++ cfe/trunk/lib/Parse/ParseAST.cpp Thu Nov 17 18:26:59 2011
@@ -79,15 +79,24 @@
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());
Modified: cfe/trunk/lib/Rewrite/RewriteObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Rewrite/RewriteObjC.cpp?rev=144943&r1=144942&r2=144943&view=diff
==============================================================================
--- cfe/trunk/lib/Rewrite/RewriteObjC.cpp (original)
+++ cfe/trunk/lib/Rewrite/RewriteObjC.cpp Thu Nov 17 18:26:59 2011
@@ -167,7 +167,7 @@
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 @@
}
HandleTopLevelSingleDecl(*I);
}
+ return true;
}
void HandleTopLevelSingleDecl(Decl *D);
void HandleDeclInMainFile(Decl *D);
Modified: cfe/trunk/tools/libclang/Indexing.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/Indexing.cpp?rev=144943&r1=144942&r2=144943&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/Indexing.cpp (original)
+++ cfe/trunk/tools/libclang/Indexing.cpp Thu Nov 17 18:26:59 2011
@@ -115,12 +115,9 @@
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
More information about the cfe-commits
mailing list