[cfe-commits] r124238 - in /cfe/trunk: lib/Sema/AnalysisBasedWarnings.cpp test/SemaCXX/return-noreturn-XFAIL.cpp test/SemaCXX/return-noreturn.cpp
Ted Kremenek
kremenek at apple.com
Tue Jan 25 14:50:47 PST 2011
Author: kremenek
Date: Tue Jan 25 16:50:47 2011
New Revision: 124238
URL: http://llvm.org/viewvc/llvm-project?rev=124238&view=rev
Log:
Fix regression in -Wreturn-type caused by not
handling all CFGElement kinds. While writing
the test case, it turned out that return-noreturn.cpp
wasn't actually testing anything since it has the wrong -W
flag. That uncovered another regression with
the handling of destructors marked noreturn. WIP.
Added:
cfe/trunk/test/SemaCXX/return-noreturn-XFAIL.cpp
- copied, changed from r124236, cfe/trunk/test/SemaCXX/return-noreturn.cpp
Modified:
cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
cfe/trunk/test/SemaCXX/return-noreturn.cpp
Modified: cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp?rev=124238&r1=124237&r2=124238&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp (original)
+++ cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp Tue Jan 25 16:50:47 2011
@@ -132,21 +132,12 @@
continue;
}
CFGElement CE = B[B.size()-1];
- if (CFGInitializer CI = CE.getAs<CFGInitializer>()) {
- // A base or member initializer.
- HasPlainEdge = true;
- continue;
- }
- if (CFGMemberDtor MD = CE.getAs<CFGMemberDtor>()) {
- // A member destructor.
- HasPlainEdge = true;
- continue;
- }
- if (CFGBaseDtor BD = CE.getAs<CFGBaseDtor>()) {
- // A base destructor.
+
+ if (!isa<CFGStmt>(CE)) {
HasPlainEdge = true;
continue;
}
+
CFGStmt CS = CE.getAs<CFGStmt>();
if (!CS.isValid())
continue;
Copied: cfe/trunk/test/SemaCXX/return-noreturn-XFAIL.cpp (from r124236, cfe/trunk/test/SemaCXX/return-noreturn.cpp)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/return-noreturn-XFAIL.cpp?p2=cfe/trunk/test/SemaCXX/return-noreturn-XFAIL.cpp&p1=cfe/trunk/test/SemaCXX/return-noreturn.cpp&r1=124236&r2=124238&rev=124238&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/return-noreturn.cpp (original)
+++ cfe/trunk/test/SemaCXX/return-noreturn-XFAIL.cpp Tue Jan 25 16:50:47 2011
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 %s -fsyntax-only -verify -Wmissing-noreturn -Wno-unreachable-code
+// RUN: %clang_cc1 %s -fsyntax-only -verify -Wreturn-type -Wno-unreachable-code
+// XFAIL: *
// A destructor may be marked noreturn and should still influence the CFG.
namespace PR6884 {
Modified: cfe/trunk/test/SemaCXX/return-noreturn.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/return-noreturn.cpp?rev=124238&r1=124237&r2=124238&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/return-noreturn.cpp (original)
+++ cfe/trunk/test/SemaCXX/return-noreturn.cpp Tue Jan 25 16:50:47 2011
@@ -1,17 +1,11 @@
-// RUN: %clang_cc1 %s -fsyntax-only -verify -Wmissing-noreturn -Wno-unreachable-code
+// RUN: %clang_cc1 %s -fsyntax-only -verify -Wreturn-type -Wno-unreachable-code
-// A destructor may be marked noreturn and should still influence the CFG.
-namespace PR6884 {
- struct abort_struct {
- abort_struct() {} // Make this non-POD so the destructor is invoked.
- ~abort_struct() __attribute__((noreturn));
- };
+// <rdar://problem/8875247> - Properly handle CFGs with destructors.
+struct rdar8875247 {
+ ~rdar8875247 ();
+};
+void rdar8875247_aux();
- int f() {
- abort_struct();
- }
-
- int f2() {
- abort_struct s;
- }
-}
+int rdar8875247_test() {
+ rdar8875247 f;
+} // expected-warning{{control reaches end of non-void function}}
More information about the cfe-commits
mailing list