15#include "llvm/ADT/StringRef.h"
16#include "llvm/ADT/Twine.h"
17#include "llvm/Support/LineIterator.h"
18#include "llvm/Support/MD5.h"
31 std::string Signature;
37 Target->getTemplateInstantiationPattern())
42 Signature.append(
Target->getReturnType().getAsString()).append(
" ");
43 Signature.append(
Target->getQualifiedNameAsString()).append(
"(");
45 for (
int i = 0, paramsCount =
Target->getNumParams(); i < paramsCount; ++i) {
47 Signature.append(
", ");
48 Signature.append(
Target->getParamDecl(i)->getType().getAsString());
52 Signature.append(
", ...");
53 Signature.append(
")");
56 llvm::dyn_cast_or_null<FunctionType>(
Target->getType().getTypePtr());
61 if (TargetT->isConst())
62 Signature.append(
" const");
63 if (TargetT->isVolatile())
64 Signature.append(
" volatile");
65 if (TargetT->isRestrict())
66 Signature.append(
" restrict");
68 if (
const auto *TargetPT =
69 dyn_cast_or_null<FunctionProtoType>(
Target->getType().getTypePtr())) {
70 switch (TargetPT->getRefQualifier()) {
72 Signature.append(
" &");
75 Signature.append(
" &&");
89 if (
const auto *ND = dyn_cast<NamedDecl>(D)) {
92 switch (ND->getKind()) {
97 DeclName = ND->getQualifiedNameAsString();
99 case Decl::CXXConstructor:
100 case Decl::CXXDestructor:
101 case Decl::CXXConversion:
102 case Decl::CXXMethod:
104 DeclName =
GetSignature(dyn_cast_or_null<FunctionDecl>(ND));
106 case Decl::ObjCMethod:
109 DeclName = ND->getQualifiedNameAsString();
126 llvm::line_iterator LI(*Buffer,
false);
127 for (; !LI.is_at_eof() && LI.line_number() !=
Line; ++LI)
135 static StringRef Whitespaces =
" \t\n";
139 StringRef::size_type col = Str.find_first_not_of(Whitespaces);
140 if (col == StringRef::npos)
146 std::optional<llvm::MemoryBufferRef> Buffer =
155 Buffer->getBufferStart(), BufferPos, Buffer->getBufferEnd());
157 size_t NextStart = 0;
158 std::ostringstream LineBuff;
166 return LineBuff.str();
171 llvm::MD5::MD5Result MD5Res;
174 Hash.update(Content);
176 llvm::MD5::stringifyResult(MD5Res, Res);
182 StringRef CheckerName,
183 StringRef WarningMessage,
184 const Decl *IssueDecl,
186 static StringRef Delimiter =
"$";
188 return (llvm::Twine(CheckerName) + Delimiter +
192 Delimiter + WarningMessage)
197 StringRef CheckerName,
198 StringRef WarningMessage,
199 const Decl *IssueDecl,
203 IssueLoc, CheckerName, WarningMessage, IssueDecl, LangOpts));
Defines the clang::ASTContext interface.
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
static std::string NormalizeLine(const SourceManager &SM, const FullSourceLoc &L, const LangOptions &LangOpts)
static llvm::SmallString< 32 > GetMD5HashOfContent(StringRef Content)
static std::string GetSignature(const FunctionDecl *Target)
static StringRef GetNthLineOfFile(std::optional< llvm::MemoryBufferRef > Buffer, int Line)
static std::string GetEnclosingDeclContextSignature(const Decl *D)
llvm::MachO::Target Target
Defines the SourceManager interface.
Decl - This represents one declaration (or definition), e.g.
A SourceLocation and its associated SourceManager.
unsigned getExpansionColumnNumber(bool *Invalid=nullptr) const
const SourceManager & getManager() const
unsigned getExpansionLineNumber(bool *Invalid=nullptr) const
Represents a function declaration or definition.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Lexer - This provides a simple interface that turns a text buffer into a stream of tokens.
bool LexFromRawLexer(Token &Result)
LexFromRawLexer - Lex a token from a designated raw lexer (one with no associated preprocessor object...
Encodes a location in the source.
This class handles loading and caching of source files into memory.
FileID getFileID(SourceLocation SpellingLoc) const
Return the FileID for a SourceLocation.
SourceLocation translateLineCol(FileID FID, unsigned Line, unsigned Col) const
Get the source location in FID for the given line:col.
const char * getCharacterData(SourceLocation SL, bool *Invalid=nullptr) const
Return a pointer to the start of the specified location in the appropriate spelling MemoryBuffer.
SourceLocation getLocForStartOfFile(FileID FID) const
Return the source location corresponding to the first byte of the specified file.
std::optional< llvm::MemoryBufferRef > getBufferOrNone(FileID FID, SourceLocation Loc=SourceLocation()) const
Return the buffer for the specified FileID.
Token - This structure provides full information about a lexed token.
SourceLocation getLocation() const
Return a source location identifier for the specified offset in the current file.
unsigned getLength() const
bool isAtStartOfLine() const
isAtStartOfLine - Return true if this token is at the start of a line.
The JSON file list parser is used to communicate input to InstallAPI.
bool isa(CodeGen::Address addr)
@ RQ_LValue
An lvalue ref-qualifier was provided (&).
@ RQ_RValue
An rvalue ref-qualifier was provided (&&).
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.