diff options
author | Mike Stump <mrs@apple.com> | 2009-07-28 23:11:12 +0000 |
---|---|---|
committer | Mike Stump <mrs@apple.com> | 2009-07-28 23:11:12 +0000 |
commit | 4d9d51ae3b868268082f94d84d0dff4c0b1ad435 (patch) | |
tree | 38a33bbab8bc8849dd068c4a324509d2fbd5ee50 /lib/Sema/SemaDecl.cpp | |
parent | 1275ae098acda31fe0e434510c729fcfed0458a1 (diff) |
Add support for -Wmissing-noreturn.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77391 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDecl.cpp')
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 7c0f849fd7..c6fb6d97bd 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -1149,10 +1149,13 @@ void Sema::CheckFallThroughForFunctionDef(Decl *D, Stmt *Body) { HasNoReturn = true; } + // Short circuit for compilation speed. if ((Diags.getDiagnosticLevel(diag::warn_maybe_falloff_nonvoid_function) == Diagnostic::Ignored || ReturnsVoid) && (Diags.getDiagnosticLevel(diag::warn_noreturn_function_has_return_expr) - == Diagnostic::Ignored || !HasNoReturn)) + == Diagnostic::Ignored || !HasNoReturn) + && (Diags.getDiagnosticLevel(diag::warn_suggest_noreturn_block) + == Diagnostic::Ignored || !ReturnsVoid)) return; // FIXME: Funtion try block if (CompoundStmt *Compound = dyn_cast<CompoundStmt>(Body)) { @@ -1170,6 +1173,8 @@ void Sema::CheckFallThroughForFunctionDef(Decl *D, Stmt *Body) { Diag(Compound->getRBracLoc(), diag::warn_falloff_nonvoid_function); break; case NeverFallThrough: + if (ReturnsVoid) + Diag(Compound->getLBracLoc(), diag::warn_suggest_noreturn_function); break; } } @@ -1197,7 +1202,11 @@ void Sema::CheckFallThroughForBlock(QualType BlockTy, Stmt *Body) { HasNoReturn = true; } - if (ReturnsVoid && !HasNoReturn) + // Short circuit for compilation speed. + if (ReturnsVoid + && !HasNoReturn + && (Diags.getDiagnosticLevel(diag::warn_suggest_noreturn_block) + == Diagnostic::Ignored || !ReturnsVoid)) return; // FIXME: Funtion try block if (CompoundStmt *Compound = dyn_cast<CompoundStmt>(Body)) { @@ -1215,6 +1224,8 @@ void Sema::CheckFallThroughForBlock(QualType BlockTy, Stmt *Body) { Diag(Compound->getRBracLoc(), diag::err_falloff_nonvoid_block); break; case NeverFallThrough: + if (ReturnsVoid) + Diag(Compound->getLBracLoc(), diag::warn_suggest_noreturn_block); break; } } |