<div dir="ltr"><div>Hi,</div><div><br></div><div>Anyone would be interested in having a unique identifier for Clang-Tidy findings? Hashing the bug and its context in a similar way as it was introduced in Clang Static Analyzer in <a href="https://reviews.llvm.org/D10305">https://reviews.llvm.org/D10305</a> would be useful e.g. to list new defects compared to a baseline and to recognize that a finding is the same even if it was shifted in the source code. The hash would assure that the issues in the following two examples could be considered as the same finding (which they are, since the difference between the two files is an unrelated change that caused the second finding to be shifted by 2 lines):</div><div><br></div><div>// test.cpp (version 1)</div><div>// 'clang-tidy test.cpp -checks=bugprone-string-constructor' output now is:</div><div>// test.cpp:4:15: warning: string constructor parameters are probably swapped; expecting string(count, character) [bugprone-string-constructor]</div><div>//   std::string str('x', 50);</div><div>//               ^   ~~~~ ~~~</div><div>//                   50   'x'</div><div>// planned string to be hashed: bugprone-string-constructor$void bugproneStringConstruct()$15$std::stringstr('x',50);</div><div>#include <string></div><div><br></div><div>void bugproneStringConstruct() { </div><div>  std::string str('x', 50);</div><div>}</div><div><br></div><div>// test.cpp (version 2)</div><div>// 'clang-tidy test.cpp -checks=bugprone-string-constructor' output now is:</div><div>// test.cpp:6:15: warning: string constructor parameters are probably swapped; expecting string(count, character) [bugprone-string-constructor]</div><div>//   std::string str('x', 50);</div><div>//               ^   ~~~~ ~~~</div><div>//                   50   'x'</div><div>// planned string to be hashed: bugprone-string-constructor$void bugproneStringConstruct()$15$std::stringstr('x',50);</div><div>#include <string></div><div><br></div><div>void bugproneStringConstruct() { </div><div>  // This function does nothing, but raises clang-tidy's </div><div>  // bugprone-string-constructor checker warning.</div><div>  std::string str('x', 50);</div><div>}</div><div><br></div><div>If such a hash could serve well the community, are there any thoughts on the implementation? Based on Clang Static Analyzer, the hash would be md5('checker name$enclosing context$column of the finding$source code line text').</div><div>I thought about two possible solutions:</div><div>  1) The hash could be part of the diagnostic message, i.e.: test.cpp:4:15: warning: string constructor parameters are probably swapped; expecting string(count, character) [bugprone-string-constructor] #0679de2a8c11b9a0e88c7e517b7301fd#</div><div>  2) The hash could be generated by an external Clang tool after the analysis, based on the location and checker information provided by the original diagnostic message. The major drawback of this approach is that Clang-Tidy's output has to parsed, and the source file has to be reparsed in order to find the enclosing context.</div><div><br></div><div>Thanks for your comments,</div><div>Lorinc</div></div>