зеркало из https://github.com/microsoft/clang-1.git
Change ASTConsumer::HandleTopLevelDecl to return true for the parser to continue
parsing or false to abort parsing. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@144943 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
b395c63b47
Коммит
88c2596edc
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
Загрузка…
Ссылка в новой задаче