[-Wunreachable-code] don't warn about dead 'return <string literal>' dominated by a 'noreturn' call, where literal becomes an std::string.
I have mixed feelings about this one. It's used all over the codebase,
and is analogous to the current heuristic for ordinary C string literals.
This requires some ad hoc pattern matching of the AST. While the
test case mirrors what we see std::string in libc++, it's not really
testing the libc++ headers.
llvm-svn: 203091
diff --git a/clang/test/SemaCXX/warn-unreachable.cpp b/clang/test/SemaCXX/warn-unreachable.cpp
index dbbcc8c..1fbe15c 100644
--- a/clang/test/SemaCXX/warn-unreachable.cpp
+++ b/clang/test/SemaCXX/warn-unreachable.cpp
@@ -129,4 +129,25 @@
return PR19040_TEST_FAILURE; // expected-warning {{will never be executed}}
}
+__attribute__((noreturn))
+void raze();
+
+namespace std {
+template<typename T> struct basic_string {
+ basic_string(const T* x) {}
+ ~basic_string() {};
+};
+typedef basic_string<char> string;
+}
+
+std::string testStr() {
+ raze();
+ return ""; // no-warning
+}
+
+std::string testStrWarn(const char *s) {
+ raze();
+ return s; // expected-warning {{will never be executed}}
+}
+