diff options
author | John McCall <rjmccall@apple.com> | 2010-05-16 09:34:11 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2010-05-16 09:34:11 +0000 |
commit | 16565aa95b086fb239baf82335dccc1b1ec93942 (patch) | |
tree | efac5c4e248460871838f272253235ca52672e25 /lib/Sema/AnalysisBasedWarnings.cpp | |
parent | 761c94e3bffef0fcb8b4bbf202fd5ee73db134f3 (diff) |
Don't emit any fallthrough / missing-noreturn warnings if we can't
compute a CFG for a function.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103905 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/AnalysisBasedWarnings.cpp')
-rw-r--r-- | lib/Sema/AnalysisBasedWarnings.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/lib/Sema/AnalysisBasedWarnings.cpp b/lib/Sema/AnalysisBasedWarnings.cpp index 6ded0a3460..21dd40b32e 100644 --- a/lib/Sema/AnalysisBasedWarnings.cpp +++ b/lib/Sema/AnalysisBasedWarnings.cpp @@ -54,8 +54,13 @@ static void CheckUnreachable(Sema &S, AnalysisContext &AC) { // Check for missing return value. //===----------------------------------------------------------------------===// -enum ControlFlowKind { NeverFallThrough = 0, MaybeFallThrough = 1, - AlwaysFallThrough = 2, NeverFallThroughOrReturn = 3 }; +enum ControlFlowKind { + UnknownFallThrough, + NeverFallThrough, + MaybeFallThrough, + AlwaysFallThrough, + NeverFallThroughOrReturn +}; /// CheckFallThrough - Check that we don't fall off the end of a /// Statement that should return a value. @@ -68,9 +73,7 @@ enum ControlFlowKind { NeverFallThrough = 0, MaybeFallThrough = 1, /// will return. static ControlFlowKind CheckFallThrough(AnalysisContext &AC) { CFG *cfg = AC.getCFG(); - if (cfg == 0) - // FIXME: This should be NeverFallThrough - return NeverFallThroughOrReturn; + if (cfg == 0) return UnknownFallThrough; // The CFG leaves in dead things, and we don't want the dead code paths to // confuse us, so we mark all live things first. @@ -290,6 +293,9 @@ static void CheckFallThroughForBody(Sema &S, const Decl *D, const Stmt *Body, // FIXME: Function try block if (const CompoundStmt *Compound = dyn_cast<CompoundStmt>(Body)) { switch (CheckFallThrough(AC)) { + case UnknownFallThrough: + break; + case MaybeFallThrough: if (HasNoReturn) S.Diag(Compound->getRBracLoc(), |