diff options
author | Ted Kremenek <kremenek@apple.com> | 2009-09-26 04:15:09 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2009-09-26 04:15:09 +0000 |
commit | 74e3c92aa3eb1750ac2eb89994046eb69db39100 (patch) | |
tree | c139566fcd8f2dfe26d525d365052287065e8ea1 /lib/Frontend/AnalysisConsumer.cpp | |
parent | 5b3a2fcd8038f27e2278f64be2c6a3beb6fae8b6 (diff) |
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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82846 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Frontend/AnalysisConsumer.cpp')
-rw-r--r-- | lib/Frontend/AnalysisConsumer.cpp | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/lib/Frontend/AnalysisConsumer.cpp b/lib/Frontend/AnalysisConsumer.cpp index d078cb7978..276599470b 100644 --- a/lib/Frontend/AnalysisConsumer.cpp +++ b/lib/Frontend/AnalysisConsumer.cpp @@ -223,30 +223,33 @@ void AnalysisConsumer::HandleTopLevelSingleDecl(Decl *D) { } void AnalysisConsumer::HandleTranslationUnit(ASTContext &C) { - // Find the entry function definition. - FunctionDecl *FD = 0; - TranslationUnitDecl *TU = Ctx->getTranslationUnitDecl(); - for (DeclContext::decl_iterator I = TU->decls_begin(), E = TU->decls_end(); - I != E; ++I) { - if (FunctionDecl *fd = dyn_cast<FunctionDecl>(*I)) - if (fd->isThisDeclarationADefinition() && - fd->getNameAsString() == Opts.AnalyzeSpecificFunction) { - FD = fd; - break; + + TranslationUnitDecl *TU = C.getTranslationUnitDecl(); + + if (!TranslationUnitActions.empty()) { + // Find the entry function definition (if any). + FunctionDecl *FD = 0; + + 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)) + if (fd->isThisDeclarationADefinition() && + fd->getNameAsString() == Opts.AnalyzeSpecificFunction) { + FD = fd; + 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); |