Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line | 
|---|---|---|---|
| 14 | pmbaty | 1 | //===---------- IssueHash.h - Generate identification hashes ----*- C++ -*-===// | 
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | #ifndef LLVM_CLANG_ANALYSIS_ISSUEHASH_H | ||
| 9 | #define LLVM_CLANG_ANALYSIS_ISSUEHASH_H | ||
| 10 | |||
| 11 | #include "llvm/ADT/SmallString.h" | ||
| 12 | |||
| 13 | namespace clang { | ||
| 14 | class Decl; | ||
| 15 | class FullSourceLoc; | ||
| 16 | class LangOptions; | ||
| 17 | |||
| 18 | /// Returns an opaque identifier for a diagnostic. | ||
| 19 | /// | ||
| 20 | /// This opaque identifier is intended to be stable even when the source code | ||
| 21 | /// is changed. It allows to track diagnostics in the long term, for example, | ||
| 22 | /// find which diagnostics are "new", maintain a database of suppressed | ||
| 23 | /// diagnostics etc. | ||
| 24 | /// | ||
| 25 | /// We may introduce more variants of issue hashes in the future | ||
| 26 | /// but older variants will still be available for compatibility. | ||
| 27 | /// | ||
| 28 | /// This hash is based on the following information: | ||
| 29 | ///   - Name of the checker that emitted the diagnostic. | ||
| 30 | ///   - Warning message. | ||
| 31 | ///   - Name of the enclosing declaration. | ||
| 32 | ///   - Contents of the line of code with the issue, excluding whitespace. | ||
| 33 | ///   - Column number (but not the line number! - which makes it stable). | ||
| 34 | llvm::SmallString<32> getIssueHash(const FullSourceLoc &IssueLoc, | ||
| 35 | llvm::StringRef CheckerName, | ||
| 36 | llvm::StringRef WarningMessage, | ||
| 37 | const Decl *IssueDecl, | ||
| 38 | const LangOptions &LangOpts); | ||
| 39 | |||
| 40 | /// Get the unhashed string representation of the V1 issue hash. | ||
| 41 | /// When hashed, it becomes the actual issue hash. Useful for testing. | ||
| 42 | /// See GetIssueHashV1() for more information. | ||
| 43 | std::string getIssueString(const FullSourceLoc &IssueLoc, | ||
| 44 | llvm::StringRef CheckerName, | ||
| 45 | llvm::StringRef WarningMessage, | ||
| 46 | const Decl *IssueDecl, const LangOptions &LangOpts); | ||
| 47 | } // namespace clang | ||
| 48 | |||
| 49 | #endif |