[cfe-commits] r82846 - /cfe/trunk/lib/Frontend/AnalysisConsumer.cpp
Ted Kremenek
kremenek at apple.com
Fri Sep 25 21:15:10 PDT 2009
Author: kremenek
Date: Fri Sep 25 23:15:09 2009
New Revision: 82846
URL: http://llvm.org/viewvc/llvm-project?rev=82846&view=rev
Log:
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.
Modified:
cfe/trunk/lib/Frontend/AnalysisConsumer.cpp
Modified: cfe/trunk/lib/Frontend/AnalysisConsumer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/AnalysisConsumer.cpp?rev=82846&r1=82845&r2=82846&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/AnalysisConsumer.cpp (original)
+++ cfe/trunk/lib/Frontend/AnalysisConsumer.cpp Fri Sep 25 23:15:09 2009
@@ -223,30 +223,33 @@
}
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);
More information about the cfe-commits
mailing list