Page MenuHomePhabricator

[analyzer] NFC: Move IssueHash to libAnalysis.
Needs ReviewPublic

Authored by NoQ on Tue, Sep 10, 4:49 PM.

Details

Summary

IssueHash is an attempt to introduce stable warning identifiers that won't change when code around them gets moved around. Path diagnostic consumers print issue hashes for the emitted diagnostics.

This move will allow us to ultimately move path diagnostic consumers to libAnalysis.

Diff Detail

Event Timeline

NoQ created this revision.Tue, Sep 10, 4:49 PM
Herald added a project: Restricted Project. · View Herald TranscriptTue, Sep 10, 4:49 PM

The "bugtype" in IssueHash is specific to Static Analyzer (or at least not documented sufficiently abstractly).

NoQ added a comment.Wed, Sep 11, 11:23 AM

The "bugtype" in IssueHash is specific to Static Analyzer (or at least not documented sufficiently abstractly).

Yeah, i'll need to document this.

That's basically the warning message; it doesn't have to have anything to do with the Analyzer's BugType structure. But if the warning message contains fragile stuff (eg., mentions a name of a variable or (why??) a line number), the user may want to wipe it out of the hash, and in this case Analyzer BugTypes turn out to be fairly handy.

NoQ updated this revision to Diff 219824.Wed, Sep 11, 4:00 PM

Rename BugType to WarningMessage, add comments.

Get rid of an unnecessary SourceManager parameter.

gribozavr added inline comments.Thu, Sep 12, 2:52 AM
clang/include/clang/Analysis/IssueHash.h
18

Returns an opaque identifier for a diagnostic.

This opaque identifier is intended to be stable even when the source code is changed. It allows to track diagnostics in the long term, for example, find which diagnostics are "new", maintain a database of suppressed diagnostics etc.

The identifier includes the following information:

  • the normalized source text...
  • ...

The identifier does not include the following information:

  • the name of the file,
  • the line and column number in the file,
  • ...
35

I don't understand what this paragraph is talking about at all. What does it mean for a new hash to be introduced? As in, when this hashing algorithm changes?

41

Why isn't IssueLoc const?

47

The doc comment suggests that this function returns a hash as a string, but that's not what it does. It returns some sort of identifier that is then hashed.