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"
54 for (StringRef::size_type i =
s.size(); i != 0; --i)
56 return s.substr(0, i);
65 : kind(k), Hint(hint) {}
82 bool ShouldFlattenMacros)
const {
83 for (
auto &Piece : *
this) {
84 switch (Piece->getKind()) {
86 auto &Call = cast<PathDiagnosticCallPiece>(*Piece);
87 if (
auto CallEnter = Call.getCallEnterEvent())
89 Call.path.flattenTo(Primary, Primary, ShouldFlattenMacros);
90 if (
auto callExit = Call.getCallExitEvent())
91 Current.push_back(std::move(callExit));
95 auto &Macro = cast<PathDiagnosticMacroPiece>(*Piece);
96 if (ShouldFlattenMacros) {
97 Macro.subPieces.flattenTo(Primary, Primary, ShouldFlattenMacros);
99 Current.push_back(Piece);
101 Macro.subPieces.flattenTo(Primary, NewPath, ShouldFlattenMacros);
103 Macro.subPieces = NewPath;
111 Current.push_back(Piece);
120 StringRef CheckerName,
const Decl *declWithIssue, StringRef bugtype,
121 StringRef verboseDesc, StringRef shortDesc, StringRef category,
123 std::unique_ptr<FilesToLineNumsMap> ExecutedLines)
124 : CheckerName(CheckerName), DeclWithIssue(declWithIssue),
129 UniqueingDecl(DeclToUnique), ExecutedLines(
std::move(ExecutedLines)),
132void PathDiagnosticConsumer::anchor() {}
141 std::unique_ptr<PathDiagnostic> D) {
142 if (!D || D->path.empty())
148 D->flattenLocations();
155 const SourceManager &SMgr = D->path.front()->getLocation().getManager();
159 llvm::raw_svector_ostream warning(buf);
160 warning <<
"warning: Path diagnostic report is not generated. Current "
161 <<
"output format does not support diagnostics that cross file "
162 <<
"boundaries. Refer to --analyzer-output for valid output "
168 for (
const auto &I : path) {
175 llvm::errs() << warning.str();
181 for (
const auto &I : Ranges) {
184 llvm::errs() << warning.str();
189 llvm::errs() << warning.str();
194 if (
const auto *call = dyn_cast<PathDiagnosticCallPiece>(piece))
196 else if (
const auto *macro = dyn_cast<PathDiagnosticMacroPiece>(piece))
197 WorkList.push_back(¯o->subPieces);
206 llvm::FoldingSetNodeID profile;
208 void *InsertPos =
nullptr;
215 const unsigned orig_size = orig->full_size();
216 const unsigned new_size = D->full_size();
217 if (orig_size <= new_size)
220 assert(orig != D.get());
221 Diags.RemoveNode(orig);
225 Diags.InsertNode(D.release());
231static std::optional<bool>
258 if (X_CEWL != Y_CEWL)
280 if (
X.getRanges().size() != Y.
getRanges().size())
281 return X.getRanges().size() < Y.
getRanges().size();
285 for (
unsigned i = 0, n =
X.getRanges().size(); i < n; ++i) {
295 switch (
X.getKind()) {
298 cast<PathDiagnosticControlFlowPiece>(Y));
301 cast<PathDiagnosticMacroPiece>(Y));
304 cast<PathDiagnosticCallPiece>(Y));
310 llvm_unreachable(
"all cases handled");
315 if (
X.size() != Y.size())
316 return X.size() < Y.size();
318 PathPieces::const_iterator X_I =
X.begin(), X_end =
X.end();
319 PathPieces::const_iterator Y_I = Y.begin(), Y_end = Y.end();
321 for (; X_I != X_end && Y_I != Y_end; ++X_I, ++Y_I)
336 std::pair<bool, bool> InSameTU =
SM.isInTheSameTranslationUnit(XOffs, YOffs);
369 auto CompareDecls = [&XL](
const Decl *D1,
370 const Decl *D2) -> std::optional<bool> {
394 if (XE - XI != YE - YI)
395 return (XE - XI) < (YE - YI);
396 for ( ; XI != XE ; ++XI, ++YI) {
398 return (*XI) < (*YI);
410 std::vector<const PathDiagnostic *> BatchDiags;
411 for (
const auto &D :
Diags)
412 BatchDiags.push_back(&D);
418 assert(*
X != *Y &&
"PathDiagnostics not uniqued!");
421 assert(
compare(**Y, **
X) &&
"Not a total order!");
424 array_pod_sort(BatchDiags.begin(), BatchDiags.end(), Comp);
429 for (
const auto D : BatchDiags)
437 for (
auto It = Set.begin(); It != Set.end();)
442 StringRef ConsumerName,
443 StringRef FileName) {
444 llvm::FoldingSetNodeID NodeID;
447 PDFileEntry *Entry = Set.FindNodeOrInsertPos(NodeID, InsertPos);
451 Set.InsertNode(Entry, InsertPos);
455 char *FileName_cstr = (
char*) Alloc.Allocate(FileName.size(), 1);
456 memcpy(FileName_cstr, FileName.data(), FileName.size());
458 Entry->
files.push_back(std::make_pair(ConsumerName,
459 StringRef(FileName_cstr,
465 llvm::FoldingSetNodeID NodeID;
468 PDFileEntry *Entry = Set.FindNodeOrInsertPos(NodeID, InsertPos);
471 return &Entry->
files;
480 SourceLocation L = UseEndOfStatement ? S->getEndLoc() : S->getBeginLoc();
481 assert(!LAC.isNull() &&
482 "A valid LocationContext or AnalysisDeclContext should be passed to "
483 "PathDiagnosticLocation upon creation.");
513 L = UseEndOfStatement ?
Parent->getEndLoc() :
Parent->getBeginLoc();
552 if (
const Stmt *CallerBody = CallerInfo->
getBody())
571 llvm_unreachable(
"not yet implemented!");
574 llvm_unreachable(
"CFGElement kind should not be on callsite!");
577 llvm_unreachable(
"Unknown CFGElement kind");
590 assert(S &&
"Statement cannot be null");
599 if (
const auto *CS = dyn_cast<CompoundStmt>(S))
600 return createEndBrace(CS,
SM);
650 if (
const auto *CS = dyn_cast_or_null<CompoundStmt>(LC->
getDecl()->
getBody()))
651 if (!CS->body_empty()) {
669 const Stmt* S =
nullptr;
670 if (std::optional<BlockEdge> BE =
P.getAs<
BlockEdge>()) {
671 const CFGBlock *BSrc = BE->getSrc();
676 P.getLocationContext()->getDecl(), SMng);
685 "TerminatorCondition and is not the enrty block of the CFG");
687 P.getLocationContext()->getDecl(), SMng);
690 }
else if (std::optional<StmtPoint> SP =
P.getAs<
StmtPoint>()) {
694 }
else if (std::optional<PostInitializer> PIP =
P.getAs<
PostInitializer>()) {
697 }
else if (std::optional<PreImplicitCall> PIC =
P.getAs<
PreImplicitCall>()) {
699 }
else if (std::optional<PostImplicitCall> PIE =
702 }
else if (std::optional<CallEnter> CE =
P.getAs<
CallEnter>()) {
704 CE->getLocationContext(),
706 }
else if (std::optional<CallExitEnd> CEE =
P.getAs<
CallExitEnd>()) {
708 CEE->getLocationContext(),
711 if (
const ReturnStmt *RS = CEB->getReturnStmt())
713 CEB->getLocationContext());
715 CEB->getLocationContext()->getDecl()->getSourceRange().getEnd(), SMng);
716 }
else if (std::optional<BlockEntrance> BE =
P.getAs<
BlockEntrance>()) {
717 if (std::optional<CFGElement> BlockFront = BE->getFirstElement()) {
718 if (
auto StmtElt = BlockFront->getAs<
CFGStmt>()) {
722 NewAllocElt->getAllocatorExpr()->getBeginLoc(), SMng);
724 llvm_unreachable(
"Unexpected CFG element at front of block");
728 BE->getBlock()->getTerminatorStmt()->getBeginLoc(), SMng);
729 }
else if (std::optional<FunctionExitPoint> FE =
732 FE->getLocationContext());
734 llvm_unreachable(
"Unexpected ProgramPoint");
783 const Stmt *S = asStmt();
784 switch (S->getStmtClass()) {
787 case Stmt::DeclStmtClass: {
788 const auto *DS = cast<DeclStmt>(S);
789 if (DS->isSingleDecl()) {
792 DS->getSingleDecl()->getLocation());
798 case Stmt::IfStmtClass:
799 case Stmt::WhileStmtClass:
800 case Stmt::DoStmtClass:
801 case Stmt::ForStmtClass:
802 case Stmt::ChooseExprClass:
803 case Stmt::IndirectGotoStmtClass:
804 case Stmt::SwitchStmtClass:
805 case Stmt::BinaryConditionalOperatorClass:
806 case Stmt::ConditionalOperatorClass:
807 case Stmt::ObjCForCollectionStmtClass: {
818 if (
const auto *MD = dyn_cast<ObjCMethodDecl>(D))
819 return MD->getSourceRange();
820 if (
const auto *FD = dyn_cast<FunctionDecl>(D)) {
821 if (
Stmt *Body = FD->getBody())
822 return Body->getSourceRange();
839 else if (K == DeclK) {
850std::shared_ptr<PathDiagnosticCallPiece>
857 return std::shared_ptr<PathDiagnosticCallPiece>(
863 const Decl *caller) {
864 std::shared_ptr<PathDiagnosticCallPiece>
C(
868 path.push_front(std::move(
C));
886 if (
const auto *MD = dyn_cast<ObjCMethodDecl>(Callee))
887 IsCalleeAnAutosynthesizedPropertyAccessor = (
888 MD->isPropertyAccessor() &&
895 StringRef Prefix = StringRef(),
896 StringRef Postfix = StringRef());
912 StringRef Prefix, StringRef Postfix) {
917 for (
int I = 0,
Last = TAList.size() - 1; I !=
Last; ++I) {
926 StringRef Prefix = StringRef()) {
929 Out << Prefix <<
'\'' << *D;
930 if (
const auto T = dyn_cast<ClassTemplateSpecializationDecl>(D))
932 D->getLangOpts(),
"<",
">");
938 bool ExtendedDescription,
939 StringRef Prefix = StringRef()) {
943 if (isa<BlockDecl>(D)) {
944 if (ExtendedDescription)
945 Out << Prefix <<
"anonymous block";
946 return ExtendedDescription;
949 if (
const auto *MD = dyn_cast<CXXMethodDecl>(D)) {
951 if (ExtendedDescription && !MD->isUserProvided()) {
952 if (MD->isExplicitlyDefaulted())
958 if (
const auto *CD = dyn_cast<CXXConstructorDecl>(MD)) {
959 if (CD->isDefaultConstructor())
961 else if (CD->isCopyConstructor())
963 else if (CD->isMoveConstructor())
966 Out <<
"constructor";
968 }
else if (isa<CXXDestructorDecl>(MD)) {
969 if (!MD->isUserProvided()) {
974 Out <<
"'" << *MD <<
"'";
976 }
else if (MD->isCopyAssignmentOperator()) {
977 Out <<
"copy assignment operator";
979 }
else if (MD->isMoveAssignmentOperator()) {
980 Out <<
"move assignment operator";
983 if (MD->getParent()->getIdentifier())
984 Out <<
"'" << *MD->getParent() <<
"::" << *MD <<
"'";
986 Out <<
"'" << *MD <<
"'";
992 Out << Prefix << '\'' << cast<NamedDecl>(*D);
995 if (
const auto FD = dyn_cast<FunctionDecl>(D))
997 FD->getTemplateSpecializationArgs())
1005std::shared_ptr<PathDiagnosticEventPiece>
1011 if (!Callee || IsCalleeAnAutosynthesizedPropertyAccessor)
1015 llvm::raw_svector_ostream Out(buf);
1020 assert(callEnter.asLocation().isValid());
1021 return std::make_shared<PathDiagnosticEventPiece>(callEnter, Out.str());
1024std::shared_ptr<PathDiagnosticEventPiece>
1026 if (!callEnterWithin.asLocation().isValid())
1028 if (Callee->isImplicit() || !Callee->hasBody())
1030 if (
const auto *MD = dyn_cast<CXXMethodDecl>(Callee))
1031 if (MD->isDefaulted())
1035 llvm::raw_svector_ostream Out(buf);
1037 Out <<
"Entered call";
1040 return std::make_shared<PathDiagnosticEventPiece>(callEnterWithin, Out.str());
1043std::shared_ptr<PathDiagnosticEventPiece>
1049 if (NoExit || IsCalleeAnAutosynthesizedPropertyAccessor)
1053 llvm::raw_svector_ostream Out(buf);
1055 if (!CallStackMessage.empty()) {
1056 Out << CallStackMessage;
1062 Out <<
"Returning to caller";
1065 assert(callReturn.asLocation().isValid());
1066 return std::make_shared<PathDiagnosticEventPiece>(callReturn, Out.str());
1070 for (
const auto &I : pieces) {
1072 if (
const auto *cp = dyn_cast<PathDiagnosticCallPiece>(piece))
1090 ID.Add(
Range.getBegin());
1091 ID.Add(
Range.getEnd());
1096 ID.AddInteger((
unsigned)
getKind());
1099 ID.AddInteger((
unsigned) getDisplayHint());
1101 for (
const auto &I : Ranges) {
1102 ID.Add(I.getBegin());
1109 for (
const auto &I : path)
1120 for (
const auto &I : *
this)
1126 for (
const auto &I : subPieces)
1139 ID.Add(getLocation());
1140 ID.Add(getUniqueingLoc());
1142 ID.AddString(VerboseDesc);
1148 for (
const auto &I : path)
1150 for (
meta_iterator I = meta_begin(), E = meta_end(); I != E; ++I)
1156 for (PathPieces::const_iterator I = begin(), E = end(); I != E; ++I) {
1157 llvm::errs() <<
"[" << index++ <<
"] ";
1159 llvm::errs() <<
"\n";
1164 llvm::errs() <<
"CALL\n--------------\n";
1166 if (
const Stmt *SLoc = getLocation().getStmtOrNull())
1168 else if (
const auto *ND = dyn_cast_or_null<NamedDecl>(getCallee()))
1169 llvm::errs() << *ND <<
"\n";
1171 getLocation().dump();
1175 llvm::errs() <<
"EVENT\n--------------\n";
1176 llvm::errs() << getString() <<
"\n";
1177 llvm::errs() <<
" ---- at ----\n";
1178 getLocation().dump();
1182 llvm::errs() <<
"CONTROL\n--------------\n";
1183 getStartLocation().dump();
1184 llvm::errs() <<
" ---- to ----\n";
1185 getEndLocation().dump();
1189 llvm::errs() <<
"MACRO\n--------------\n";
1194 llvm::errs() <<
"NOTE\n--------------\n";
1195 llvm::errs() << getString() <<
"\n";
1196 llvm::errs() <<
" ---- at ----\n";
1197 getLocation().dump();
1201 llvm::errs() <<
"POP-UP\n--------------\n";
1202 llvm::errs() << getString() <<
"\n";
1203 llvm::errs() <<
" ---- at ----\n";
1204 getLocation().dump();
1209 llvm::errs() <<
"<INVALID>\n";
1216 llvm::errs() <<
"<range>\n";
1219 asLocation().dump();
1220 llvm::errs() <<
"\n";
1226 llvm::errs() <<
"<NULL STMT>\n";
1229 if (
const auto *ND = dyn_cast_or_null<NamedDecl>(D))
1230 llvm::errs() << *ND <<
"\n";
1231 else if (isa<BlockDecl>(D))
1233 llvm::errs() <<
"<block>\n";
1235 llvm::errs() <<
"<unknown decl>\n";
1237 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 CXXNewExpr * getAllocatorExpr() const
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
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
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
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
@ C
Languages that the frontend can parse and compile.
@ Result
The result type of a method or function.
Describes how types, statements, expressions, and declarations should be printed.