r201607 - Experiment with making -Wunreachable-code more immediately useful by restricting warnings to those issued in the main file.

David Blaikie dblaikie at gmail.com
Fri Feb 21 11:53:33 PST 2014


On Tue, Feb 18, 2014 at 2:28 PM, David Blaikie <dblaikie at gmail.com> wrote:

>
>
>
> On Tue, Feb 18, 2014 at 2:12 PM, Ted Kremenek <kremenek at apple.com> wrote:
>
>> Author: kremenek
>> Date: Tue Feb 18 16:12:10 2014
>> New Revision: 201607
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=201607&view=rev
>> Log:
>> Experiment with making -Wunreachable-code more immediately useful by
>> restricting warnings to those issued in the main file.
>>
>
> Seems simple enough (though one of these days I'll dredge up the CFG edge
> improvements again to start fixing this more completely) - but a simple
> test case would be nice to have too.
>

Bump for test case?


>
>
>> This warning has a whole bunch of known false positives, much of them due
>> to code that is "sometimes unreachable".  This can caused by code that
>> is conditionally generated by the preprocessor, branches that are defined
>> in terms of architecture-specific details (e.g., the size of a type), and
>> so on.  While these are all good things to address one by one, the reality
>> is that this warning has received little love lately.  By restricting
>> its purvue, we can focus on the top issues effecting main files, which
>> should be smaller, and then gradually widen the scope.
>>
>> Modified:
>>     cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
>>
>> Modified: cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp?rev=201607&r1=201606&r2=201607&view=diff
>>
>> ==============================================================================
>> --- cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp (original)
>> +++ cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp Tue Feb 18 16:12:10 2014
>> @@ -66,6 +66,12 @@ namespace {
>>      UnreachableCodeHandler(Sema &s) : S(s) {}
>>
>>      void HandleUnreachable(SourceLocation L, SourceRange R1, SourceRange
>> R2) {
>> +      // As a heuristic prune all diagnostics not in the main file.
>>  Currently
>> +      // the majority of warnings in headers are false positives.  These
>> +      // are largely caused by configuration state, e.g. preprocessor
>> +      // defined code, etc.
>> +      if (!S.getSourceManager().isInMainFile(L))
>> +        return;
>>        S.Diag(L, diag::warn_unreachable) << R1 << R2;
>>      }
>>    };
>>
>>
>> _______________________________________________
>> cfe-commits mailing list
>> cfe-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140221/14df8615/attachment.html>


More information about the cfe-commits mailing list