Hoist some branches in AnalysisManager::HandleTranslationUnit so we
avoid scanning for an "entry point" FunctionDecl if we (a) have no translation unit actions and (b) no entry point function has been specified. llvm-svn: 82846
This commit is contained in:
parent
0374742326
commit
9a4e5663d2
|
@ -223,9 +223,14 @@ void AnalysisConsumer::HandleTopLevelSingleDecl(Decl *D) {
|
|||
}
|
||||
|
||||
void AnalysisConsumer::HandleTranslationUnit(ASTContext &C) {
|
||||
// Find the entry function definition.
|
||||
|
||||
TranslationUnitDecl *TU = C.getTranslationUnitDecl();
|
||||
|
||||
if (!TranslationUnitActions.empty()) {
|
||||
// Find the entry function definition (if any).
|
||||
FunctionDecl *FD = 0;
|
||||
TranslationUnitDecl *TU = Ctx->getTranslationUnitDecl();
|
||||
|
||||
if (!Opts.AnalyzeSpecificFunction.empty()) {
|
||||
for (DeclContext::decl_iterator I=TU->decls_begin(), E=TU->decls_end();
|
||||
I != E; ++I) {
|
||||
if (FunctionDecl *fd = dyn_cast<FunctionDecl>(*I))
|
||||
|
@ -235,18 +240,16 @@ void AnalysisConsumer::HandleTranslationUnit(ASTContext &C) {
|
|||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!TranslationUnitActions.empty()) {
|
||||
for (Actions::iterator I = TranslationUnitActions.begin(),
|
||||
E = TranslationUnitActions.end(); I != E; ++I)
|
||||
(*I)(*Mgr, FD);
|
||||
}
|
||||
|
||||
if (!ObjCImplementationActions.empty()) {
|
||||
TranslationUnitDecl *TUD = C.getTranslationUnitDecl();
|
||||
|
||||
for (DeclContext::decl_iterator I = TUD->decls_begin(),
|
||||
E = TUD->decls_end();
|
||||
for (DeclContext::decl_iterator I = TU->decls_begin(),
|
||||
E = TU->decls_end();
|
||||
I != E; ++I)
|
||||
if (ObjCImplementationDecl* ID = dyn_cast<ObjCImplementationDecl>(*I))
|
||||
HandleCode(ID, 0, ObjCImplementationActions);
|
||||
|
|
Loading…
Reference in New Issue