diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -60,7 +60,7 @@ "remove call to max function and unsigned zero argument">; def warn_infinite_recursive_function : Warning< - "all paths through this function will call itself">, + "In order to understand recursion, you must first understand recursion">, InGroup, DefaultIgnore; def warn_comma_operator : Warning<"possible misuse of comma operator here">, diff --git a/clang/test/SemaCXX/warn-infinite-recursion.cpp b/clang/test/SemaCXX/warn-infinite-recursion.cpp --- a/clang/test/SemaCXX/warn-infinite-recursion.cpp +++ b/clang/test/SemaCXX/warn-infinite-recursion.cpp @@ -1,14 +1,14 @@ // RUN: %clang_cc1 %s -fsyntax-only -verify -Winfinite-recursion -void a() { // expected-warning{{call itself}} +void a() { // expected-warning{{to understand recursion}} a(); } -void b(int x) { // expected-warning{{call itself}} +void b(int x) { // expected-warning{{to understand recursion}} if (x) b(x); else - b(x+1); + b(x + 1); } void c(int x) { @@ -16,7 +16,7 @@ c(5); } -void d(int x) { // expected-warning{{call itself}} +void d(int x) { // expected-warning{{to understand recursion}} if (x) ++x; return d(x); @@ -29,7 +29,7 @@ void e() { f(); } void f() { e(); } -void g() { // expected-warning{{call itself}} +void g() { // expected-warning{{to understand recursion}} while (true) g(); @@ -38,41 +38,43 @@ void h(int x) { while (x < 5) { - h(x+1); + h(x + 1); } } -void i(int x) { // expected-warning{{call itself}} +void i(int x) { // expected-warning{{to understand recursion}} while (x < 5) { --x; } i(0); } -int j() { // expected-warning{{call itself}} +int j() { // expected-warning{{to understand recursion}} return 5 + j(); } // Don't warn on infinite loops void k() { - while(true) { + while (true) { k(); } } void l() { - while (true) {} + while (true) { + } l(); } void m() { static int count = 5; - if (count >0) { + if (count > 0) { count--; l(); } - while (true) {} + while (true) { + } } class S { @@ -80,11 +82,11 @@ void b(); }; -void S::a() { // expected-warning{{call itself}} +void S::a() { // expected-warning{{to understand recursion}} return a(); } -void S::b() { // expected-warning{{call itself}} +void S::b() { // expected-warning{{to understand recursion}} int i = 0; do { ++i; @@ -92,72 +94,72 @@ } while (i > 5); } -template +template struct T { member m; - void a() { return a(); } // expected-warning{{call itself}} - static void b() { return b(); } // expected-warning{{call itself}} + void a() { return a(); } // expected-warning{{to understand recursion}} + static void b() { return b(); } // expected-warning{{to understand recursion}} }; void test_T() { T foo; - foo.a(); // expected-note{{in instantiation}} - foo.b(); // expected-note{{in instantiation}} + foo.a(); // expected-note{{in instantiation}} + foo.b(); // expected-note{{in instantiation}} } class U { - U* u; - void Fun() { // expected-warning{{call itself}} + U *u; + void Fun() { // expected-warning{{to understand recursion}} u->Fun(); } }; // No warnings on templated functions -// sum<0>() is instantiated, does recursively call itself, but never runs. +// sum<0>() is instantiated, does recursively to understand recursion, but never runs. template int sum() { - return value + sum(); + return value + sum(); } -template<> +template <> int sum<1>() { return 1; } -template +template int calculate_value() { if (x != y) - return sum(); // This instantiates sum<0>() even if never called. + return sum(); // This instantiates sum<0>() even if never called. else return 0; } -int value = calculate_value<1,1>(); +int value = calculate_value<1, 1>(); void DoSomethingHere(); // DoStuff<0,0>() is instantiated, but never called. -template +template int DoStuff() { if (First + 1 == Last) { // This branch gets removed during <0, 0> instantiation in so CFG for this // function goes straight to the else branch. DoSomethingHere(); } else { - DoStuff(); - DoStuff<(First + Last)/2, Last>(); + DoStuff(); + DoStuff<(First + Last) / 2, Last>(); } return 0; } int stuff = DoStuff<0, 1>(); -template +template struct Wrapper { static int run() { // Similar to the above, Wrapper<0>::run() will discard the if statement. if (x == 1) return 0; - return Wrapper::run(); + return Wrapper::run(); } - static int run2() { // expected-warning{{call itself}} + static int run2() { // expected-warning{{to understand recursion}} return run2(); } }; @@ -166,8 +168,8 @@ int test_wrapper() { if (x != 0) return Wrapper::run() + - Wrapper::run2(); // expected-note{{instantiation}} + Wrapper::run2(); // expected-note{{instantiation}} return 0; } -int wrapper_sum = test_wrapper<2>(); // expected-note{{instantiation}} +int wrapper_sum = test_wrapper<2>(); // expected-note{{instantiation}}