From: Anna Zaks Date: Tue, 13 Mar 2012 19:31:54 +0000 (+0000) Subject: [analyzer] Minor: factor out logic for determining if we should skip a X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=98520835eb1aa091429afa06e9f4f7ebe3864d34;p=clang [analyzer] Minor: factor out logic for determining if we should skip a function. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152649 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp b/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp index 54be4f7bcf..d4d5911740 100644 --- a/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp +++ b/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp @@ -191,6 +191,7 @@ public: void HandleDeclContextDeclFunction(ASTContext &C, Decl *D); void HandleCode(Decl *D, SetOfDecls *VisitedCallees = 0); + bool skipFunction(Decl *D); void RunPathSensitiveChecks(Decl *D, SetOfDecls *VisitedCallees); void ActionExprEngine(Decl *D, bool ObjCGCEnabled, SetOfDecls *VisitedCallees); }; @@ -384,20 +385,28 @@ static std::string getFunctionName(const Decl *D) { return ""; } -void AnalysisConsumer::HandleCode(Decl *D, SetOfDecls *VisitedCallees) { +bool AnalysisConsumer::skipFunction(Decl *D) { if (!Opts.AnalyzeSpecificFunction.empty() && getFunctionName(D) != Opts.AnalyzeSpecificFunction) - return; - - DisplayFunction(D); + return true; // Don't run the actions on declarations in header files unless // otherwise specified. SourceManager &SM = Ctx->getSourceManager(); SourceLocation SL = SM.getExpansionLoc(D->getLocation()); if (!Opts.AnalyzeAll && !SM.isFromMainFile(SL)) + return true; + + return false; +} + +void AnalysisConsumer::HandleCode(Decl *D, SetOfDecls *VisitedCallees) { + + if (skipFunction(D)) return; + DisplayFunction(D); + // Clear the AnalysisManager of old AnalysisDeclContexts. Mgr->ClearContexts();