clang 19.0.0git
IssueHash.h
Go to the documentation of this file.
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
13namespace clang {
14class Decl;
15class FullSourceLoc;
16class 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).
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.
43std::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
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:85
A SourceLocation and its associated SourceManager.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Definition: LangOptions.h:454
@ Decl
The l-value was an access to a declared entity or something equivalently strong, like the address of ...
The JSON file list parser is used to communicate input to InstallAPI.
llvm::SmallString< 32 > getIssueHash(const FullSourceLoc &IssueLoc, llvm::StringRef CheckerName, llvm::StringRef WarningMessage, const Decl *IssueDecl, const LangOptions &LangOpts)
Returns an opaque identifier for a diagnostic.
std::string getIssueString(const FullSourceLoc &IssueLoc, llvm::StringRef CheckerName, llvm::StringRef WarningMessage, const Decl *IssueDecl, const LangOptions &LangOpts)
Get the unhashed string representation of the V1 issue hash.