]> granicus.if.org Git - clang/blob - include/clang/StaticAnalyzer/Core/IssueHash.h
913ab7964fb80dfe47a52b4e635ad1ad17a251ed
[clang] / include / clang / StaticAnalyzer / Core / IssueHash.h
1 //===---------- IssueHash.h - Generate identification hashes ----*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_CLANG_STATICANALYZER_CORE_ISSUE_HASH_H
10 #define LLVM_CLANG_STATICANALYZER_CORE_ISSUE_HASH_H
11
12 #include "llvm/ADT/SmallString.h"
13
14 namespace clang {
15 class Decl;
16 class SourceManager;
17 class FullSourceLoc;
18
19 /// \brief Get an MD5 hash to help identify bugs.
20 ///
21 /// This function returns a hash that helps identify bugs within a source file.
22 /// This identification can be utilized to diff diagnostic results on different
23 /// snapshots of a projects, or maintain a database of suppressed diagnotics.
24 ///
25 /// The hash contains the normalized text of the location associated with the
26 /// diagnostic. Normalization means removing the whitespaces. The associated
27 /// location is the either the last location of a diagnostic path or a uniqueing
28 /// location. The bugtype and the name of the checker is also part of the hash.
29 /// The last component is the string representation of the enclosing declaration
30 /// of the associated location.
31 /// 
32 /// In case a new hash is introduced, the old one should still be maintained for
33 /// a while. One should not introduce a new hash for every change, it is
34 /// possible to introduce experimental hashes that may change in the future.
35 /// Such hashes should be marked as experimental using a comment in the plist
36 /// files.
37 llvm::SmallString<32> GetIssueHash(const SourceManager &SM,
38                                    FullSourceLoc &IssueLoc,
39                                    llvm::StringRef CheckerName,
40                                    llvm::StringRef BugType, const Decl *D);
41
42 /// \brief Get the string representation of issue hash. See GetIssueHash() for
43 /// more information.
44 std::string GetIssueString(const SourceManager &SM, FullSourceLoc &IssueLoc,
45                            llvm::StringRef CheckerName, llvm::StringRef BugType,
46                            const Decl *D);
47 } // namespace clang
48
49 #endif