[cfe-commits] r100800 - in /cfe/trunk/lib/Sema: AnalysisBasedWarnings.cpp AnalysisBasedWarnings.h

Ted Kremenek kremenek at apple.com
Thu Apr 8 11:51:44 PDT 2010


Author: kremenek
Date: Thu Apr  8 13:51:44 2010
New Revision: 100800

URL: http://llvm.org/viewvc/llvm-project?rev=100800&view=rev
Log:
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.

Modified:
    cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
    cfe/trunk/lib/Sema/AnalysisBasedWarnings.h

Modified: cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp?rev=100800&r1=100799&r2=100800&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp (original)
+++ cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp Thu Apr  8 13:51:44 2010
@@ -323,8 +323,7 @@
 
 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 @@
     // 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 @@
   // 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 @@
       (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;
-                    }
-                  }
-                }
-              }
-      }
-    }
-  }
 }

Modified: cfe/trunk/lib/Sema/AnalysisBasedWarnings.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/AnalysisBasedWarnings.h?rev=100800&r1=100799&r2=100800&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/AnalysisBasedWarnings.h (original)
+++ cfe/trunk/lib/Sema/AnalysisBasedWarnings.h Thu Apr  8 13:51:44 2010
@@ -47,9 +47,7 @@
 
   Policy getDefaultPolicy() { return DefaultPolicy; }
 
-  void IssueWarnings(Policy P, const Decl *D, QualType BlockTy = QualType(),
-                     const bool analyzeStaticInline = false);
-
+  void IssueWarnings(Policy P, const Decl *D, QualType BlockTy = QualType());
 };
 
 }} // end namespace clang::sema





More information about the cfe-commits mailing list