diff options
author | Ted Kremenek <kremenek@apple.com> | 2010-04-08 18:51:44 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2010-04-08 18:51:44 +0000 |
commit | b7e5f145f47b6ec1db1ba6fe9db9c0ed2fe38db3 (patch) | |
tree | bdafe4364ce13f79da1e51d9928e609fa7a09295 /lib/Sema/AnalysisBasedWarnings.cpp | |
parent | c53d0d762010217d02da5aa14be171817d63e3fe (diff) |
Remove micro-optimization for not issueing CFG-based warnings for 'static inline' functions
unless they are used. I discussed this with Daniel Dunbar, and we agreed that this
provides an inconsistent warnings experience for the user and that there were
genuine cases where we wouldn't want to do this optimization.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100800 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/AnalysisBasedWarnings.cpp')
-rw-r--r-- | lib/Sema/AnalysisBasedWarnings.cpp | 61 |
1 files changed, 2 insertions, 59 deletions
diff --git a/lib/Sema/AnalysisBasedWarnings.cpp b/lib/Sema/AnalysisBasedWarnings.cpp index 3281924f43..8c42caf8bc 100644 --- a/lib/Sema/AnalysisBasedWarnings.cpp +++ b/lib/Sema/AnalysisBasedWarnings.cpp @@ -323,8 +323,7 @@ clang::sema::AnalysisBasedWarnings::AnalysisBasedWarnings(Sema &s) : S(s) { void clang::sema:: AnalysisBasedWarnings::IssueWarnings(sema::AnalysisBasedWarnings::Policy P, - const Decl *D, QualType BlockTy, - const bool analyzeStaticInline) { + const Decl *D, QualType BlockTy) { assert(BlockTy.isNull() || isa<BlockDecl>(D)); @@ -348,17 +347,6 @@ AnalysisBasedWarnings::IssueWarnings(sema::AnalysisBasedWarnings::Policy P, // we'll do the analysis at instantiation time. if (FD->isDependentContext()) return; - - // Only analyze 'static inline' functions when explicitly asked. - if (!analyzeStaticInline && FD->isInlineSpecified() && - FD->getStorageClass() == FunctionDecl::Static) { - FD = FD->getCanonicalDecl(); - VisitFlag &visitFlag = VisitedFD[FD]; - if (visitFlag == Pending) - visitFlag = Visited; - else - return; - } } const Stmt *Body = D->getBody(); @@ -367,7 +355,6 @@ AnalysisBasedWarnings::IssueWarnings(sema::AnalysisBasedWarnings::Policy P, // Don't generate EH edges for CallExprs as we'd like to avoid the n^2 // explosion for destrutors that can result and the compile time hit. AnalysisContext AC(D, false); - bool performedCheck = false; // Warning: check missing 'return' if (P.enableCheckFallThrough) { @@ -375,53 +362,9 @@ AnalysisBasedWarnings::IssueWarnings(sema::AnalysisBasedWarnings::Policy P, (isa<BlockDecl>(D) ? CheckFallThroughDiagnostics::MakeForBlock() : CheckFallThroughDiagnostics::MakeForFunction()); CheckFallThroughForBody(S, D, Body, BlockTy, CD, AC); - performedCheck = true; } // Warning: check for unreachable code - if (P.enableCheckUnreachable) { + if (P.enableCheckUnreachable) CheckUnreachable(S, AC); - performedCheck = true; - } - - // If this block or function calls a 'static inline' function, - // we should analyze those functions as well. - if (performedCheck) { - // The CFG should already be constructed, so this should not - // incur any extra cost. We might not have a CFG, however, for - // invalid code. - if (const CFG *cfg = AC.getCFG()) { - // All CallExprs are block-level expressions in the CFG. This means - // that walking the basic blocks in the CFG is more efficient - // than walking the entire AST to find all calls. - for (CFG::const_iterator I=cfg->begin(), E=cfg->end(); I!=E; ++I) { - const CFGBlock *B = *I; - for (CFGBlock::const_iterator BI=B->begin(), BE=B->end(); BI!=BE; ++BI) - if (const CallExpr *CE = dyn_cast<CallExpr>(*BI)) - if (const DeclRefExpr *DR = - dyn_cast<DeclRefExpr>(CE->getCallee()->IgnoreParenCasts())) - if (const FunctionDecl *calleeD = - dyn_cast<FunctionDecl>(DR->getDecl())) { - calleeD = calleeD->getCanonicalDecl(); - if (calleeD->isInlineSpecified() && - calleeD->getStorageClass() == FunctionDecl::Static) { - // Have we analyzed this static inline function before? - VisitFlag &visitFlag = VisitedFD[calleeD]; - if (visitFlag == NotVisited) { - // Mark the callee visited prior to analyzing it - // so we terminate in case of recursion. - if (calleeD->getBody()) { - visitFlag = Visited; - IssueWarnings(DefaultPolicy, calleeD, QualType(), true); - } - else { - // Delay warnings until we encounter the definition. - visitFlag = Pending; - } - } - } - } - } - } - } } |