Assertion in BugReport::getLocation()?

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

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 ) the stored location was asserted to be invalid 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.