33#include "llvm/ADT/ArrayRef.h"
34#include "llvm/ADT/FoldingSet.h"
35#include "llvm/ADT/STLExtras.h"
36#include "llvm/ADT/SmallString.h"
37#include "llvm/ADT/SmallVector.h"
38#include "llvm/ADT/StringExtras.h"
39#include "llvm/ADT/StringRef.h"
40#include "llvm/Support/Casting.h"
41#include "llvm/Support/ErrorHandling.h"
42#include "llvm/Support/raw_ostream.h"
60 : kind(k), Hint(hint) {}
77 bool ShouldFlattenMacros)
const {
78 for (
auto &Piece : *
this) {
79 switch (Piece->getKind()) {
81 auto &
Call = cast<PathDiagnosticCallPiece>(*Piece);
84 Call.path.flattenTo(Primary, Primary, ShouldFlattenMacros);
85 if (
auto callExit =
Call.getCallExitEvent())
86 Current.push_back(std::move(callExit));
90 auto &Macro = cast<PathDiagnosticMacroPiece>(*Piece);
91 if (ShouldFlattenMacros) {
92 Macro.subPieces.flattenTo(Primary, Primary, ShouldFlattenMacros);
94 Current.push_back(Piece);
96 Macro.subPieces.flattenTo(Primary, NewPath, ShouldFlattenMacros);
98 Macro.subPieces = NewPath;
106 Current.push_back(Piece);
115 StringRef CheckerName,
const Decl *declWithIssue, StringRef bugtype,
116 StringRef verboseDesc, StringRef shortDesc, StringRef category,
118 const Decl *AnalysisEntryPoint,
119 std::unique_ptr<FilesToLineNumsMap> ExecutedLines)
120 : CheckerName(CheckerName), DeclWithIssue(declWithIssue),
125 UniqueingDecl(DeclToUnique), AnalysisEntryPoint(AnalysisEntryPoint),
126 ExecutedLines(
std::move(ExecutedLines)), path(pathImpl) {
127 assert(AnalysisEntryPoint);
130void PathDiagnosticConsumer::anchor() {}
139 std::unique_ptr<PathDiagnostic>
D) {
140 if (!
D ||
D->path.empty())
146 D->flattenLocations();
157 llvm::raw_svector_ostream warning(buf);
158 warning <<
"warning: Path diagnostic report is not generated. Current "
159 <<
"output format does not support diagnostics that cross file "
160 <<
"boundaries. Refer to --analyzer-output for valid output "
166 for (
const auto &I : path) {
173 llvm::errs() << warning.str();
179 for (
const auto &I : Ranges) {
182 llvm::errs() << warning.str();
187 llvm::errs() << warning.str();
192 if (
const auto *call = dyn_cast<PathDiagnosticCallPiece>(piece))
194 else if (
const auto *macro = dyn_cast<PathDiagnosticMacroPiece>(piece))
195 WorkList.push_back(¯o->subPieces);
204 llvm::FoldingSetNodeID profile;
206 void *InsertPos =
nullptr;
213 const unsigned orig_size = orig->full_size();
214 const unsigned new_size =
D->full_size();
215 if (orig_size <= new_size)
218 assert(orig !=
D.get());
219 Diags.RemoveNode(orig);
223 Diags.InsertNode(
D.release());
229static std::optional<bool>
256 if (X_CEWL != Y_CEWL)
278 if (
X.getRanges().size() != Y.
getRanges().size())
279 return X.getRanges().size() < Y.
getRanges().size();
283 for (
unsigned i = 0, n =
X.getRanges().size(); i < n; ++i) {
293 switch (
X.getKind()) {
296 cast<PathDiagnosticControlFlowPiece>(Y));
299 cast<PathDiagnosticMacroPiece>(Y));
302 cast<PathDiagnosticCallPiece>(Y));
308 llvm_unreachable(
"all cases handled");
313 if (
X.size() != Y.size())
314 return X.size() < Y.size();
316 PathPieces::const_iterator X_I =
X.begin(), X_end =
X.end();
317 PathPieces::const_iterator Y_I = Y.begin(), Y_end = Y.end();
319 for (; X_I != X_end && Y_I != Y_end; ++X_I, ++Y_I)
334 std::pair<bool, bool> InSameTU =
SM.isInTheSameTranslationUnit(XOffs, YOffs);
367 auto CompareDecls = [&XL](
const Decl *D1,
368 const Decl *D2) -> std::optional<bool> {
392 if (XE - XI != YE - YI)
393 return (XE - XI) < (YE - YI);
394 for ( ; XI != XE ; ++XI, ++YI) {
396 return (*XI) < (*YI);
408 std::vector<const PathDiagnostic *> BatchDiags;
409 for (
const auto &
D :
Diags)
410 BatchDiags.push_back(&
D);
416 assert(*
X != *Y &&
"PathDiagnostics not uniqued!");
419 assert(
compare(**Y, **
X) &&
"Not a total order!");
422 array_pod_sort(BatchDiags.begin(), BatchDiags.end(), Comp);
427 for (
const auto D : BatchDiags)
435 for (
auto It = Set.begin(); It != Set.end();)
440 StringRef ConsumerName,
442 llvm::FoldingSetNodeID NodeID;
449 Set.InsertNode(Entry, InsertPos);
453 char *FileName_cstr = (
char*) Alloc.Allocate(
FileName.size(), 1);
456 Entry->
files.push_back(std::make_pair(ConsumerName,
457 StringRef(FileName_cstr,
463 llvm::FoldingSetNodeID NodeID;
469 return &Entry->
files;
478 SourceLocation L = UseEndOfStatement ? S->getEndLoc() : S->getBeginLoc();
479 assert(!LAC.isNull() &&
480 "A valid LocationContext or AnalysisDeclContext should be passed to "
481 "PathDiagnosticLocation upon creation.");
511 L = UseEndOfStatement ?
Parent->getEndLoc() :
Parent->getBeginLoc();
550 if (
const Stmt *CallerBody = CallerInfo->
getBody())
569 llvm_unreachable(
"not yet implemented!");
572 llvm_unreachable(
"CFGElement kind should not be on callsite!");
575 llvm_unreachable(
"Unknown CFGElement kind");
588 assert(S &&
"Statement cannot be null");
597 if (
const auto *CS = dyn_cast<CompoundStmt>(S))
598 return createEndBrace(CS,
SM);
648 if (
const auto *CS = dyn_cast_or_null<CompoundStmt>(LC->
getDecl()->
getBody()))
649 if (!CS->body_empty()) {
667 const Stmt* S =
nullptr;
668 if (std::optional<BlockEdge> BE =
P.getAs<
BlockEdge>()) {
669 const CFGBlock *BSrc = BE->getSrc();
674 P.getLocationContext()->getDecl(), SMng);
683 "TerminatorCondition and is not the enrty block of the CFG");
685 P.getLocationContext()->getDecl(), SMng);
688 }
else if (std::optional<StmtPoint> SP =
P.getAs<
StmtPoint>()) {
692 }
else if (std::optional<PostInitializer> PIP =
P.getAs<
PostInitializer>()) {
695 }
else if (std::optional<PreImplicitCall> PIC =
P.getAs<
PreImplicitCall>()) {
697 }
else if (std::optional<PostImplicitCall> PIE =
700 }
else if (std::optional<CallEnter> CE =
P.getAs<
CallEnter>()) {
702 CE->getLocationContext(),
704 }
else if (std::optional<CallExitEnd> CEE =
P.getAs<
CallExitEnd>()) {
706 CEE->getLocationContext(),
709 if (
const ReturnStmt *RS = CEB->getReturnStmt())
711 CEB->getLocationContext());
713 CEB->getLocationContext()->getDecl()->getSourceRange().getEnd(), SMng);
714 }
else if (std::optional<BlockEntrance> BE =
P.getAs<
BlockEntrance>()) {
715 if (std::optional<CFGElement> BlockFront = BE->getFirstElement()) {
716 if (
auto StmtElt = BlockFront->getAs<
CFGStmt>()) {
720 NewAllocElt->getAllocatorExpr()->getBeginLoc(), SMng);
722 llvm_unreachable(
"Unexpected CFG element at front of block");
726 BE->getBlock()->getTerminatorStmt()->getBeginLoc(), SMng);
727 }
else if (std::optional<FunctionExitPoint> FE =
730 FE->getLocationContext());
732 llvm_unreachable(
"Unexpected ProgramPoint");
781 const Stmt *S = asStmt();
782 switch (S->getStmtClass()) {
785 case Stmt::DeclStmtClass: {
786 const auto *DS = cast<DeclStmt>(S);
787 if (DS->isSingleDecl()) {
790 DS->getSingleDecl()->getLocation());
796 case Stmt::IfStmtClass:
797 case Stmt::WhileStmtClass:
798 case Stmt::DoStmtClass:
799 case Stmt::ForStmtClass:
800 case Stmt::ChooseExprClass:
801 case Stmt::IndirectGotoStmtClass:
802 case Stmt::SwitchStmtClass:
803 case Stmt::BinaryConditionalOperatorClass:
804 case Stmt::ConditionalOperatorClass:
805 case Stmt::ObjCForCollectionStmtClass: {
816 if (
const auto *MD = dyn_cast<ObjCMethodDecl>(
D))
817 return MD->getSourceRange();
818 if (
const auto *FD = dyn_cast<FunctionDecl>(
D)) {
819 if (
Stmt *Body = FD->getBody())
820 return Body->getSourceRange();
837 else if (K == DeclK) {
848std::shared_ptr<PathDiagnosticCallPiece>
855 return std::shared_ptr<PathDiagnosticCallPiece>(
861 const Decl *caller) {
862 std::shared_ptr<PathDiagnosticCallPiece>
C(
866 path.push_front(std::move(
C));
884 if (
const auto *MD = dyn_cast<ObjCMethodDecl>(Callee))
885 IsCalleeAnAutosynthesizedPropertyAccessor = (
886 MD->isPropertyAccessor() &&
893 StringRef Prefix = StringRef(),
894 StringRef Postfix = StringRef());
910 StringRef Prefix, StringRef Postfix) {
915 for (
int I = 0,
Last = TAList.size() - 1; I !=
Last; ++I) {
924 StringRef Prefix = StringRef()) {
925 if (!
D->getIdentifier())
927 Out << Prefix <<
'\'' << *
D;
928 if (
const auto T = dyn_cast<ClassTemplateSpecializationDecl>(
D))
936 bool ExtendedDescription,
937 StringRef Prefix = StringRef()) {
941 if (isa<BlockDecl>(
D)) {
942 if (ExtendedDescription)
943 Out << Prefix <<
"anonymous block";
944 return ExtendedDescription;
947 if (
const auto *MD = dyn_cast<CXXMethodDecl>(
D)) {
949 if (ExtendedDescription && !MD->isUserProvided()) {
950 if (MD->isExplicitlyDefaulted())
956 if (
const auto *CD = dyn_cast<CXXConstructorDecl>(MD)) {
957 if (CD->isDefaultConstructor())
959 else if (CD->isCopyConstructor())
961 else if (CD->isMoveConstructor())
964 Out <<
"constructor";
966 }
else if (isa<CXXDestructorDecl>(MD)) {
967 if (!MD->isUserProvided()) {
972 Out <<
"'" << *MD <<
"'";
974 }
else if (MD->isCopyAssignmentOperator()) {
975 Out <<
"copy assignment operator";
977 }
else if (MD->isMoveAssignmentOperator()) {
978 Out <<
"move assignment operator";
981 if (MD->getParent()->getIdentifier())
982 Out <<
"'" << *MD->getParent() <<
"::" << *MD <<
"'";
984 Out <<
"'" << *MD <<
"'";
990 Out << Prefix << '\'' << cast<NamedDecl>(*
D);
993 if (
const auto FD = dyn_cast<FunctionDecl>(
D))
995 FD->getTemplateSpecializationArgs())
1003std::shared_ptr<PathDiagnosticEventPiece>
1009 if (!Callee || IsCalleeAnAutosynthesizedPropertyAccessor)
1013 llvm::raw_svector_ostream Out(buf);
1018 assert(callEnter.asLocation().isValid());
1019 return std::make_shared<PathDiagnosticEventPiece>(callEnter, Out.str());
1022std::shared_ptr<PathDiagnosticEventPiece>
1024 if (!callEnterWithin.asLocation().isValid())
1026 if (Callee->isImplicit() || !Callee->hasBody())
1028 if (
const auto *MD = dyn_cast<CXXMethodDecl>(Callee))
1029 if (MD->isDefaulted())
1033 llvm::raw_svector_ostream Out(buf);
1035 Out <<
"Entered call";
1038 return std::make_shared<PathDiagnosticEventPiece>(callEnterWithin, Out.str());
1041std::shared_ptr<PathDiagnosticEventPiece>
1047 if (NoExit || IsCalleeAnAutosynthesizedPropertyAccessor)
1051 llvm::raw_svector_ostream Out(buf);
1053 if (!CallStackMessage.empty()) {
1054 Out << CallStackMessage;
1060 Out <<
"Returning to caller";
1063 assert(callReturn.asLocation().isValid());
1064 return std::make_shared<PathDiagnosticEventPiece>(callReturn, Out.str());
1068 for (
const auto &I : pieces) {
1070 if (
const auto *cp = dyn_cast<PathDiagnosticCallPiece>(piece))
1088 ID.Add(
Range.getBegin());
1089 ID.Add(
Range.getEnd());
1094 ID.AddInteger((
unsigned)
getKind());
1097 ID.AddInteger((
unsigned) getDisplayHint());
1099 for (
const auto &I : Ranges) {
1100 ID.Add(I.getBegin());
1107 for (
const auto &I : path)
1118 for (
const auto &I : *
this)
1124 for (
const auto &I : subPieces)
1137 ID.Add(getLocation());
1138 ID.Add(getUniqueingLoc());
1140 ID.AddString(VerboseDesc);
1146 for (
const auto &I : path)
1154 for (PathPieces::const_iterator I = begin(),
E = end(); I !=
E; ++I) {
1155 llvm::errs() <<
"[" << index++ <<
"] ";
1157 llvm::errs() <<
"\n";
1162 llvm::errs() <<
"CALL\n--------------\n";
1164 if (
const Stmt *SLoc = getLocation().getStmtOrNull())
1166 else if (
const auto *ND = dyn_cast_or_null<NamedDecl>(getCallee()))
1167 llvm::errs() << *ND <<
"\n";
1169 getLocation().dump();
1173 llvm::errs() <<
"EVENT\n--------------\n";
1174 llvm::errs() << getString() <<
"\n";
1175 llvm::errs() <<
" ---- at ----\n";
1176 getLocation().dump();
1180 llvm::errs() <<
"CONTROL\n--------------\n";
1181 getStartLocation().dump();
1182 llvm::errs() <<
" ---- to ----\n";
1183 getEndLocation().dump();
1187 llvm::errs() <<
"MACRO\n--------------\n";
1192 llvm::errs() <<
"NOTE\n--------------\n";
1193 llvm::errs() << getString() <<
"\n";
1194 llvm::errs() <<
" ---- at ----\n";
1195 getLocation().dump();
1199 llvm::errs() <<
"POP-UP\n--------------\n";
1200 llvm::errs() << getString() <<
"\n";
1201 llvm::errs() <<
" ---- at ----\n";
1202 getLocation().dump();
1207 llvm::errs() <<
"<INVALID>\n";
1214 llvm::errs() <<
"<range>\n";
1217 asLocation().dump();
1218 llvm::errs() <<
"\n";
1224 llvm::errs() <<
"<NULL STMT>\n";
1227 if (
const auto *ND = dyn_cast_or_null<NamedDecl>(
D))
1228 llvm::errs() << *ND <<
"\n";
1229 else if (isa<BlockDecl>(
D))
1231 llvm::errs() <<
"<block>\n";
1233 llvm::errs() <<
"<unknown decl>\n";
1235 llvm::errs() <<
"<NULL DECL>\n";
This file defines AnalysisDeclContext, a class that manages the analysis context data for context sen...
static Decl::Kind getKind(const Decl *D)
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
Defines the C++ template declaration subclasses.
Defines the clang::Expr interface and subclasses for C++ expressions.
Defines the clang::FileManager interface and associated types.
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
static DiagnosticBuilder Diag(DiagnosticsEngine *Diags, const LangOptions &Features, FullSourceLoc TokLoc, const char *TokBegin, const char *TokRangeBegin, const char *TokRangeEnd, unsigned DiagID)
Produce a diagnostic highlighting some portion of a literal.
static std::optional< bool > comparePath(const PathPieces &X, const PathPieces &Y)
static PathDiagnosticLocation getLocationForCaller(const StackFrameContext *SFC, const LocationContext *CallerCtx, const SourceManager &SM)
static void describeClass(raw_ostream &Out, const CXXRecordDecl *D, StringRef Prefix=StringRef())
static bool compare(const PathDiagnostic &X, const PathDiagnostic &Y)
static bool describeCodeDecl(raw_ostream &Out, const Decl *D, bool ExtendedDescription, StringRef Prefix=StringRef())
static std::optional< bool > compareCall(const PathDiagnosticCallPiece &X, const PathDiagnosticCallPiece &Y)
static std::optional< bool > comparePiece(const PathDiagnosticPiece &X, const PathDiagnosticPiece &Y)
static void describeTemplateParameter(raw_ostream &Out, const TemplateArgument &TArg, const LangOptions &LO)
static void compute_path_size(const PathPieces &pieces, unsigned &size)
static std::optional< bool > compareMacro(const PathDiagnosticMacroPiece &X, const PathDiagnosticMacroPiece &Y)
static std::optional< bool > compareControlFlow(const PathDiagnosticControlFlowPiece &X, const PathDiagnosticControlFlowPiece &Y)
static StringRef StripTrailingDots(StringRef s)
static void describeTemplateParameters(raw_ostream &Out, const ArrayRef< TemplateArgument > TAList, const LangOptions &LO, StringRef Prefix=StringRef(), StringRef Postfix=StringRef())
static bool compareCrossTUSourceLocs(FullSourceLoc XL, FullSourceLoc YL)
Defines the clang::SourceLocation class and associated facilities.
Defines the SourceManager interface.
C Language Family Type Representation.
__DEVICE__ void * memcpy(void *__a, const void *__b, size_t __c)
__device__ __2f16 float __ockl_bool s
SourceLocation getColonLoc() const
AnalysisDeclContext contains the context data for the function, method or block under analysis.
ParentMap & getParentMap()
const Decl * getDecl() const
bool isBodyAutosynthesized() const
A builtin binary operation expression such as "x + y" or "x <= y".
SourceLocation getOperatorLoc() const
Represents C++ object destructor implicitly generated for automatic object or temporary bound to cons...
const Stmt * getTriggerStmt() const
Represents a single basic block in a source-level CFG.
CFGTerminator getTerminator() const
Stmt * getTerminatorCondition(bool StripParens=true)
Represents C++ object destructor generated from a call to delete.
const CXXDeleteExpr * getDeleteExpr() const
Represents a top-level expression in a basic block.
T castAs() const
Convert to the specified CFGElement type, asserting that this CFGElement is of the desired type.
Represents C++ base or member initializer from constructor's initialization list.
Represents C++ allocator call.
const Stmt * getStmt() const
Represents C++ object destructor implicitly generated at the end of full expression for temporary obj...
bool isVirtualBaseBranch() const
Represents a C++ struct/union/class.
Represents a point when we begin processing an inlined call.
const StackFrameContext * getCalleeContext() const
Represents a point when we start the call exit sequence (for inlined call).
Represents a point when we finish the call exit sequence (for inlined call).
const StackFrameContext * getCalleeContext() const
CompoundStmt - This represents a group of statements like { stmt stmt }.
SourceLocation getLBracLoc() const
SourceLocation getRBracLoc() const
ConditionalOperator - The ?: ternary operator.
Decl - This represents one declaration (or definition), e.g.
SourceLocation getEndLoc() const LLVM_READONLY
virtual Stmt * getBody() const
getBody - If this Decl represents a declaration for a body of code, such as a function or method defi...
SourceLocation getBodyRBrace() const
getBodyRBrace - Gets the right brace of the body, if a body exists.
SourceLocation getLocation() const
SourceLocation getBeginLoc() const LLVM_READONLY
const LangOptions & getLangOpts() const LLVM_READONLY
Helper to get the language options from the ASTContext.
StringRef getName() const
The name of this FileEntry.
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
A SourceLocation and its associated SourceManager.
FullSourceLoc getExpansionLoc() const
FullSourceLoc getSpellingLoc() const
std::pair< FileID, unsigned > getDecomposedLoc() const
Decompose the specified location into a raw FileID + Offset pair.
const SourceManager & getManager() const
bool isBeforeInTranslationUnitThan(SourceLocation Loc) const
Determines the order of 2 source locations in the translation unit.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
It wraps the AnalysisDeclContext to represent both the call stack with the help of StackFrameContext ...
const Decl * getDecl() const
LLVM_ATTRIBUTE_RETURNS_NONNULL AnalysisDeclContext * getAnalysisDeclContext() const
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
SourceLocation getMemberLoc() const
getMemberLoc - Return the location of the "member", in X->F, it is the location of 'F'.
SourceLocation getBeginLoc() const LLVM_READONLY
Represents a program point just after an implicit call event.
Represents a point after we ran remove dead bindings AFTER processing the given statement.
Represents a program point just before an implicit call event.
const LocationContext * getLocationContext() const
ReturnStmt - This represents a return, optionally of an expression: return; return 4;.
Encodes a location in the source.
bool isValid() const
Return true if this is a valid SourceLocation object.
This class handles loading and caching of source files into memory.
FileID getFileID(SourceLocation SpellingLoc) const
Return the FileID for a SourceLocation.
SourceLocation getExpansionLoc(SourceLocation Loc) const
Given a SourceLocation object Loc, return the expansion location referenced by the ID.
A trivial tuple used to represent a source range.
SourceLocation getEnd() const
SourceLocation getBegin() const
It represents a stack frame of the call stack (based on CallEvent).
unsigned getIndex() const
const CFGBlock * getCallSiteBlock() const
Stmt - This represents one statement.
SourceLocation getBeginLoc() const LLVM_READONLY
A template argument list.
Represents a template argument.
ArrayRef< TemplateArgument > getPackAsArray() const
Return the array of arguments in this template argument pack.
void print(const PrintingPolicy &Policy, raw_ostream &Out, bool IncludeType) const
Print this template argument to the given output stream.
@ Pack
The template argument is actually a parameter pack.
ArgKind getKind() const
Return the kind of stored template argument.
~PathDiagnosticCallPiece() override
void setCallee(const CallEnter &CE, const SourceManager &SM)
PathDiagnosticLocation callEnter
void dump() const override
std::shared_ptr< PathDiagnosticEventPiece > getCallExitEvent() const
static std::shared_ptr< PathDiagnosticCallPiece > construct(const CallExitEnd &CE, const SourceManager &SM)
PathDiagnosticLocation callReturn
std::shared_ptr< PathDiagnosticEventPiece > getCallEnterWithinCallerEvent() const
void Profile(llvm::FoldingSetNodeID &ID) const override
std::shared_ptr< PathDiagnosticEventPiece > getCallEnterEvent() const
PathDiagnosticLocation callEnterWithin
PDFileEntry::ConsumerFiles * getFiles(const PathDiagnostic &PD)
void addDiagnostic(const PathDiagnostic &PD, StringRef ConsumerName, StringRef fileName)
std::vector< std::pair< StringRef, StringRef > > ConsumerFiles
ConsumerFiles files
A vector of <consumer,file> pairs.
virtual void FlushDiagnosticsImpl(std::vector< const PathDiagnostic * > &Diags, FilesMade *filesMade)=0
virtual bool supportsCrossFileDiagnostics() const
Return true if the PathDiagnosticConsumer supports individual PathDiagnostics that span multiple file...
void HandlePathDiagnostic(std::unique_ptr< PathDiagnostic > D)
llvm::FoldingSet< PathDiagnostic > Diags
virtual ~PathDiagnosticConsumer()
void FlushDiagnostics(FilesMade *FilesMade)
PathDiagnosticLocation getStartLocation() const
void dump() const override
~PathDiagnosticControlFlowPiece() override
PathDiagnosticLocation getEndLocation() const
void Profile(llvm::FoldingSetNodeID &ID) const override
~PathDiagnosticEventPiece() override
void dump() const override
static PathDiagnosticLocation createMemberLoc(const MemberExpr *ME, const SourceManager &SM)
For member expressions, return the location of the '.
static PathDiagnosticLocation createDeclBegin(const LocationContext *LC, const SourceManager &SM)
Create a location for the beginning of the enclosing declaration body.
void Profile(llvm::FoldingSetNodeID &ID) const
static PathDiagnosticLocation createOperatorLoc(const BinaryOperator *BO, const SourceManager &SM)
Create the location for the operator of the binary expression.
static PathDiagnosticLocation createEndBrace(const CompoundStmt *CS, const SourceManager &SM)
Create a location for the end of the compound statement.
static PathDiagnosticLocation createBeginBrace(const CompoundStmt *CS, const SourceManager &SM)
Create a location for the beginning of the compound statement.
static SourceLocation getValidSourceLocation(const Stmt *S, LocationOrAnalysisDeclContext LAC, bool UseEndOfStatement=false)
Construct a source location that corresponds to either the beginning or the end of the given statemen...
static PathDiagnosticLocation createEnd(const Stmt *S, const SourceManager &SM, const LocationOrAnalysisDeclContext LAC)
Create a location for the end of the statement.
static PathDiagnosticLocation createBegin(const Decl *D, const SourceManager &SM)
Create a location for the beginning of the declaration.
FullSourceLoc asLocation() const
static PathDiagnosticLocation create(const Decl *D, const SourceManager &SM)
Create a location corresponding to the given declaration.
static PathDiagnosticLocation createConditionalColonLoc(const ConditionalOperator *CO, const SourceManager &SM)
static PathDiagnosticLocation createDeclEnd(const LocationContext *LC, const SourceManager &SM)
Constructs a location for the end of the enclosing declaration body.
static PathDiagnosticLocation createSingleLocation(const PathDiagnosticLocation &PDL)
Convert the given location into a single kind location.
void dump() const override
void Profile(llvm::FoldingSetNodeID &ID) const override
~PathDiagnosticMacroPiece() override
void Profile(llvm::FoldingSetNodeID &ID) const override
void dump() const override
~PathDiagnosticNotePiece() override
ArrayRef< SourceRange > getRanges() const
Return the SourceRanges associated with this PathDiagnosticPiece.
virtual PathDiagnosticLocation getLocation() const =0
virtual void Profile(llvm::FoldingSetNodeID &ID) const
virtual ~PathDiagnosticPiece()
PathDiagnosticPiece()=delete
StringRef getString() const
void Profile(llvm::FoldingSetNodeID &ID) const override
PathDiagnostic - PathDiagnostic objects represent a single path-sensitive diagnostic.
meta_iterator meta_end() const
void FullProfile(llvm::FoldingSetNodeID &ID) const
Profiles the diagnostic, including its path.
PathDiagnosticLocation getUniqueingLoc() const
Get the location on which the report should be uniqued.
std::deque< std::string >::const_iterator meta_iterator
StringRef getVerboseDescription() const
const Decl * getDeclWithIssue() const
Return the semantic context where an issue occurred.
void Profile(llvm::FoldingSetNodeID &ID) const
Profiles the diagnostic, independent of the path it references.
unsigned full_size()
Return the unrolled size of the path.
StringRef getBugType() const
const Decl * getUniqueingDecl() const
Get the declaration containing the uniqueing location.
StringRef getCategory() const
StringRef getShortDescription() const
meta_iterator meta_begin() const
PathDiagnosticLocation getLocation() const
A Range represents the closed range [from, to].
llvm::PointerUnion< const LocationContext *, AnalysisDeclContext * > LocationOrAnalysisDeclContext
The JSON file list parser is used to communicate input to InstallAPI.
@ Result
The result type of a method or function.
const FunctionProtoType * T
Describes how types, statements, expressions, and declarations should be printed.