From: Sean Hunt Date: Fri, 15 Jun 2012 21:22:05 +0000 (+0000) Subject: Stop referring to functions as methods in per-function fallthrough-checking. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c2f51cfefd77e9b25f201ecf879343d6d9a45158;p=clang Stop referring to functions as methods in per-function fallthrough-checking. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158545 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Basic/DiagnosticGroups.td b/include/clang/Basic/DiagnosticGroups.td index 571012fe95..978e951acf 100644 --- a/include/clang/Basic/DiagnosticGroups.td +++ b/include/clang/Basic/DiagnosticGroups.td @@ -209,9 +209,10 @@ def MethodDuplicate : DiagGroup<"duplicate-method-match">; def CoveredSwitchDefault : DiagGroup<"covered-switch-default">; def SwitchEnum : DiagGroup<"switch-enum">; def Switch : DiagGroup<"switch">; -def ImplicitFallthroughPerMethod : DiagGroup<"implicit-fallthrough-per-method">; +def ImplicitFallthroughPerFunction : + DiagGroup<"implicit-fallthrough-per-function">; def ImplicitFallthrough : DiagGroup<"implicit-fallthrough", - [ImplicitFallthroughPerMethod]>; + [ImplicitFallthroughPerFunction]>; def Trigraphs : DiagGroup<"trigraphs">; def : DiagGroup<"type-limits">; diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td index eff5bab77d..e861892aba 100644 --- a/include/clang/Basic/DiagnosticSemaKinds.td +++ b/include/clang/Basic/DiagnosticSemaKinds.td @@ -5316,9 +5316,9 @@ def warn_missing_cases : Warning< def warn_unannotated_fallthrough : Warning< "unannotated fall-through between switch labels">, InGroup, DefaultIgnore; -def warn_unannotated_fallthrough_per_method : Warning< - "unannotated fall-through between switch labels in partly annotated method">, - InGroup, DefaultIgnore; +def warn_unannotated_fallthrough_per_function : Warning< + "unannotated fall-through between switch labels in partly-annotated " + "function">, InGroup, DefaultIgnore; def note_insert_fallthrough_fixit : Note< "insert '[[clang::fallthrough]];' to silence this warning">; def note_insert_break_fixit : Note< diff --git a/lib/Sema/AnalysisBasedWarnings.cpp b/lib/Sema/AnalysisBasedWarnings.cpp index 7eba772743..1d74d7f765 100644 --- a/lib/Sema/AnalysisBasedWarnings.cpp +++ b/lib/Sema/AnalysisBasedWarnings.cpp @@ -821,14 +821,14 @@ namespace { } static void DiagnoseSwitchLabelsFallthrough(Sema &S, AnalysisDeclContext &AC, - bool PerMethod) { + bool PerFunction) { FallthroughMapper FM(S); FM.TraverseStmt(AC.getBody()); if (!FM.foundSwitchStatements()) return; - if (PerMethod && FM.getFallthroughStmts().empty()) + if (PerFunction && FM.getFallthroughStmts().empty()) return; CFG *Cfg = AC.getCFG(); @@ -849,8 +849,8 @@ static void DiagnoseSwitchLabelsFallthrough(Sema &S, AnalysisDeclContext &AC, continue; S.Diag(Label->getLocStart(), - PerMethod ? diag::warn_unannotated_fallthrough_per_method - : diag::warn_unannotated_fallthrough); + PerFunction ? diag::warn_unannotated_fallthrough_per_function + : diag::warn_unannotated_fallthrough); if (!AnnotatedCnt) { SourceLocation L = Label->getLocStart(); @@ -1339,10 +1339,10 @@ AnalysisBasedWarnings::IssueWarnings(sema::AnalysisBasedWarnings::Policy P, bool FallThroughDiagFull = Diags.getDiagnosticLevel(diag::warn_unannotated_fallthrough, D->getLocStart()) != DiagnosticsEngine::Ignored; - bool FallThroughDiagPerMethod = - Diags.getDiagnosticLevel(diag::warn_unannotated_fallthrough_per_method, + bool FallThroughDiagPerFunction = + Diags.getDiagnosticLevel(diag::warn_unannotated_fallthrough_per_function, D->getLocStart()) != DiagnosticsEngine::Ignored; - if (FallThroughDiagFull || FallThroughDiagPerMethod) { + if (FallThroughDiagFull || FallThroughDiagPerFunction) { DiagnoseSwitchLabelsFallthrough(S, AC, !FallThroughDiagFull); } diff --git a/test/SemaCXX/switch-implicit-fallthrough-per-method.cpp b/test/SemaCXX/switch-implicit-fallthrough-per-method.cpp index 3ca8590d39..9f9f5924a0 100644 --- a/test/SemaCXX/switch-implicit-fallthrough-per-method.cpp +++ b/test/SemaCXX/switch-implicit-fallthrough-per-method.cpp @@ -1,18 +1,18 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 -Wimplicit-fallthrough-per-method %s +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 -Wimplicit-fallthrough-per-function %s int fallthrough(int n) { switch (n / 10) { case 0: n += 100; - case 1: // expected-warning{{unannotated fall-through between switch labels in partly annotated method}} expected-note{{insert '[[clang::fallthrough]];' to silence this warning}} expected-note{{insert 'break;' to avoid fall-through}} + case 1: // expected-warning{{unannotated fall-through}} expected-note{{insert '[[clang::fallthrough]];' to silence this warning}} expected-note{{insert 'break;' to avoid fall-through}} switch (n) { case 111: n += 111; [[clang::fallthrough]]; case 112: n += 112; - case 113: // expected-warning{{unannotated fall-through between switch labels in partly annotated method}} expected-note{{insert '[[clang::fallthrough]];' to silence this warning}} expected-note{{insert 'break;' to avoid fall-through}} + case 113: // expected-warning{{unannotated fall-through}} expected-note{{insert '[[clang::fallthrough]];' to silence this warning}} expected-note{{insert 'break;' to avoid fall-through}} n += 113; break ; }