summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2010-04-08 18:51:44 +0000
committerTed Kremenek <kremenek@apple.com>2010-04-08 18:51:44 +0000
commitafed24b472a04ef54c2883b1ce04a28d7756c74b (patch)
tree57f911f7c1a44f798a6e60fcb3ab201b4e96cf7b /clang/lib/Sema
parentd87bd77586b85ce6f6578d20ac76c3c1ec2fa916 (diff)
downloadbcm5719-llvm-afed24b472a04ef54c2883b1ce04a28d7756c74b.tar.gz
bcm5719-llvm-afed24b472a04ef54c2883b1ce04a28d7756c74b.zip
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. llvm-svn: 100800
Diffstat (limited to 'clang/lib/Sema')
-rw-r--r--clang/lib/Sema/AnalysisBasedWarnings.cpp61
-rw-r--r--clang/lib/Sema/AnalysisBasedWarnings.h4
2 files changed, 3 insertions, 62 deletions
diff --git a/clang/lib/Sema/AnalysisBasedWarnings.cpp b/clang/lib/Sema/AnalysisBasedWarnings.cpp
index 3281924f43e..8c42caf8bcf 100644
--- a/clang/lib/Sema/AnalysisBasedWarnings.cpp
+++ b/clang/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;
- }
- }
- }
- }
- }
- }
- }
}
diff --git a/clang/lib/Sema/AnalysisBasedWarnings.h b/clang/lib/Sema/AnalysisBasedWarnings.h
index b5db8af198f..dea19ba28cc 100644
--- a/clang/lib/Sema/AnalysisBasedWarnings.h
+++ b/clang/lib/Sema/AnalysisBasedWarnings.h
@@ -47,9 +47,7 @@ public:
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
OpenPOWER on IntegriCloud