[cfe-dev] Assertion in BugReport::getLocation()?

Artem Dergachev via cfe-dev cfe-dev at lists.llvm.org
Mon Sep 30 18:23:13 PDT 2019


I'm confused.

This assertion applies only to path-insensitive reports into which you 
supply the PathDiagnosticLocation manually. For such reports you can 
check the location for validity before you put it into the report.

For path-sensitive reports the location is computed dynamically based on 
the error node's ProgramPoint and it's not immediately checked for 
validity. In the old code (before https://reviews.llvm.org/D66572) the 
stored location was asserted to be *in*valid because the information was 
already present in the error node; after said patch path sensitive 
reports don't store the location at all.

One of the reasons why a path-sensitive report may have invalid path 
diagnostic location is that the underlying source location may be 
invalid, eg. comes from a BodyFarm.

On 9/30/19 6:25 AM, Ádám Balogh via cfe-dev wrote:
>
> Hello,
>
> We have a checker that we plan to open source, but it crashes upon a 
> strange assertion. We create a non-fatal `BugReport` which we try to 
> emit. Before emitting the code tries to check whether its location is 
> valid using `getLocation(…).isValid()`, to prevent assertion in 
> `emit()`, however `getLocation()` itself already asserts that the 
> location is valid. This makes the `isValid()` function useless because 
> we cannot get the location to check whether its is valid because it 
> crashes with assertion if it is not. Of course the location should be 
> valid in a non-fatal error node (probably this is the root problem), 
> but there is no way to check it. What is the reason for this assertion 
> in `getLocation()`? How to check its validity? What can make the 
> location of a non-fatal `BugReport` invalid? Thanks for the answers in 
> advance!
>
> Regards,
>
> Ádám
>
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20190930/0b434e00/attachment.html>


More information about the cfe-dev mailing list