aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/clang14/include/clang/Analysis/IssueHash.h
blob: 9ccf55d4c6f43bfc0bc5f4f4fa50001dda9e901a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#pragma once

#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"
#endif

//===---------- IssueHash.h - Generate identification hashes ----*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_CLANG_ANALYSIS_ISSUEHASH_H
#define LLVM_CLANG_ANALYSIS_ISSUEHASH_H

#include "llvm/ADT/SmallString.h"

namespace clang {
class Decl;
class FullSourceLoc;
class LangOptions;

/// 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.
///
/// We may introduce more variants of issue hashes in the future
/// but older variants will still be available for compatibility.
///
/// This hash is based on the following information:
///   - Name of the checker that emitted the diagnostic.
///   - Warning message.
///   - Name of the enclosing declaration.
///   - Contents of the line of code with the issue, excluding whitespace.
///   - Column number (but not the line number! - which makes it stable).
llvm::SmallString<32> getIssueHash(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.
/// When hashed, it becomes the actual issue hash. Useful for testing.
/// See GetIssueHashV1() for more information.
std::string getIssueString(const FullSourceLoc &IssueLoc,
                           llvm::StringRef CheckerName,
                           llvm::StringRef WarningMessage,
                           const Decl *IssueDecl, const LangOptions &LangOpts);
} // namespace clang

#endif

#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif