r203336 - [-Wunreachabe-code] Don't warn about unreachable destructors for temporaries.
David Blaikie
dblaikie at gmail.com
Fri Mar 7 18:38:36 PST 2014
On Fri, Mar 7, 2014 at 6:22 PM, Ted Kremenek <kremenek at apple.com> wrote:
> Author: kremenek
> Date: Fri Mar 7 20:22:32 2014
> New Revision: 203336
>
> URL: http://llvm.org/viewvc/llvm-project?rev=203336&view=rev
> Log:
> [-Wunreachabe-code] Don't warn about unreachable destructors for temporaries.
Can a noreturn function exit by throwing? If so then the dtors are all
perfectly reachable. (and I guess your change makes that happen, so it
might just be correct without refinement)
>
> This can possibly be refined later, but right now the experience
> is so incomprehensible for a user to understand what is going on
> this isn't a useful warning.
>
> Modified:
> cfe/trunk/lib/Analysis/ReachableCode.cpp
> cfe/trunk/test/SemaCXX/warn-unreachable.cpp
>
> Modified: cfe/trunk/lib/Analysis/ReachableCode.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/ReachableCode.cpp?rev=203336&r1=203335&r2=203336&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Analysis/ReachableCode.cpp (original)
> +++ cfe/trunk/lib/Analysis/ReachableCode.cpp Fri Mar 7 20:22:32 2014
> @@ -397,9 +397,11 @@ const Stmt *DeadCodeScan::findDeadCode(c
> }
>
> if (CFGTerminator T = Block->getTerminator()) {
> - const Stmt *S = T.getStmt();
> - if (isValidDeadStmt(S))
> - return S;
> + if (!T.isTemporaryDtorsBranch()) {
> + const Stmt *S = T.getStmt();
> + if (isValidDeadStmt(S))
> + return S;
> + }
> }
>
> return 0;
>
> Modified: cfe/trunk/test/SemaCXX/warn-unreachable.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-unreachable.cpp?rev=203336&r1=203335&r2=203336&view=diff
> ==============================================================================
> --- cfe/trunk/test/SemaCXX/warn-unreachable.cpp (original)
> +++ cfe/trunk/test/SemaCXX/warn-unreachable.cpp Fri Mar 7 20:22:32 2014
> @@ -162,3 +162,16 @@ int test_global_as_conditionVariable() {
> return 0; // no-warning
> }
>
> +// Handle unreachable temporary destructors.
> +class A {
> +public:
> + A();
> + ~A();
> +};
> +
> +__attribute__((noreturn))
> +void raze(const A& x);
> +
> +void test_with_unreachable_tmp_dtors(int x) {
> + raze(x ? A() : A()); // no-warning
> +}
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
More information about the cfe-commits
mailing list