clang  13.0.0git
PathDiagnostic.h
Go to the documentation of this file.
1 //===- PathDiagnostic.h - Path-Specific Diagnostic Handling -----*- 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 //
9 // This file defines the PathDiagnostic-related interfaces.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef LLVM_CLANG_STATICANALYZER_CORE_BUGREPORTER_PATHDIAGNOSTIC_H
14 #define LLVM_CLANG_STATICANALYZER_CORE_BUGREPORTER_PATHDIAGNOSTIC_H
15 
16 #include "clang/AST/Stmt.h"
18 #include "clang/Basic/LLVM.h"
20 #include "llvm/ADT/ArrayRef.h"
21 #include "llvm/ADT/FoldingSet.h"
22 #include "llvm/ADT/Optional.h"
23 #include "llvm/ADT/PointerUnion.h"
24 #include "llvm/ADT/SmallVector.h"
25 #include "llvm/ADT/StringRef.h"
26 #include "llvm/Support/Allocator.h"
27 #include <cassert>
28 #include <deque>
29 #include <iterator>
30 #include <list>
31 #include <map>
32 #include <memory>
33 #include <set>
34 #include <string>
35 #include <utility>
36 #include <vector>
37 
38 namespace clang {
39 
40 class AnalysisDeclContext;
41 class BinaryOperator;
42 class CallEnter;
43 class CallExitEnd;
44 class CallExpr;
45 class ConditionalOperator;
46 class Decl;
47 class Expr;
48 class LocationContext;
49 class MemberExpr;
50 class ProgramPoint;
51 class SourceManager;
52 
53 namespace ento {
54 
55 //===----------------------------------------------------------------------===//
56 // High-level interface for handlers of path-sensitive diagnostics.
57 //===----------------------------------------------------------------------===//
58 
59 class PathDiagnostic;
60 
61 /// These options tweak the behavior of path diangostic consumers.
62 /// Most of these options are currently supported by very few consumers.
64  /// Run-line of the tool that produced the diagnostic.
65  /// It can be included with the diagnostic for debugging purposes.
67 
68  /// Whether to include additional information about macro expansions
69  /// with the diagnostics, because otherwise they can be hard to obtain
70  /// without re-compiling the program under analysis.
72 
73  /// Whether to include LLVM statistics of the process in the diagnostic.
74  /// Useful for profiling the tool on large real-world codebases.
75  bool ShouldSerializeStats = false;
76 
77  /// If the consumer intends to produce multiple output files, should it
78  /// use randomly generated file names for these files (with the tiny risk of
79  /// having random collisions) or deterministic human-readable file names
80  /// (with a larger risk of deterministic collisions or invalid characters
81  /// in the file name). We should not really give this choice to the users
82  /// because deterministic mode is always superior when done right, but
83  /// for some consumers this mode is experimental and needs to be
84  /// off by default.
86 
87  /// Whether the consumer should treat consumed diagnostics as hard errors.
88  /// Useful for breaking your build when issues are found.
90 
91  /// Whether the consumer should attempt to rewrite the source file
92  /// with fix-it hints attached to the diagnostics it consumes.
93  bool ShouldApplyFixIts = false;
94 
95  /// Whether the consumer should present the name of the entity that emitted
96  /// the diagnostic (eg., a checker) so that the user knew how to disable it.
98 };
99 
101 public:
102  class PDFileEntry : public llvm::FoldingSetNode {
103  public:
104  PDFileEntry(llvm::FoldingSetNodeID &NodeID) : NodeID(NodeID) {}
105 
106  using ConsumerFiles = std::vector<std::pair<StringRef, StringRef>>;
107 
108  /// A vector of <consumer,file> pairs.
110 
111  /// A precomputed hash tag used for uniquing PDFileEntry objects.
112  const llvm::FoldingSetNodeID NodeID;
113 
114  /// Used for profiling in the FoldingSet.
115  void Profile(llvm::FoldingSetNodeID &ID) { ID = NodeID; }
116  };
117 
118  class FilesMade {
119  llvm::BumpPtrAllocator Alloc;
120  llvm::FoldingSet<PDFileEntry> Set;
121 
122  public:
123  ~FilesMade();
124 
125  bool empty() const { return Set.empty(); }
126 
127  void addDiagnostic(const PathDiagnostic &PD,
128  StringRef ConsumerName,
129  StringRef fileName);
130 
132  };
133 
134 private:
135  virtual void anchor();
136 
137 public:
138  PathDiagnosticConsumer() = default;
139  virtual ~PathDiagnosticConsumer();
140 
141  void FlushDiagnostics(FilesMade *FilesMade);
142 
143  virtual void FlushDiagnosticsImpl(std::vector<const PathDiagnostic *> &Diags,
144  FilesMade *filesMade) = 0;
145 
146  virtual StringRef getName() const = 0;
147 
148  void HandlePathDiagnostic(std::unique_ptr<PathDiagnostic> D);
149 
151  /// Only runs visitors, no output generated.
153 
154  /// Used for HTML, SARIF, and text output.
156 
157  /// Used for plist output, used for "arrows" generation.
159  };
160 
162 
164  return getGenerationScheme() != None;
165  }
166 
167  bool shouldAddPathEdges() const { return getGenerationScheme() == Extensive; }
168 
169  virtual bool supportsLogicalOpControlFlow() const { return false; }
170 
171  /// Return true if the PathDiagnosticConsumer supports individual
172  /// PathDiagnostics that span multiple files.
173  virtual bool supportsCrossFileDiagnostics() const { return false; }
174 
175 protected:
176  bool flushed = false;
177  llvm::FoldingSet<PathDiagnostic> Diags;
178 };
179 
180 //===----------------------------------------------------------------------===//
181 // Path-sensitive diagnostics.
182 //===----------------------------------------------------------------------===//
183 
185 public:
186  bool isPoint = false;
187 
188  PathDiagnosticRange(SourceRange R, bool isP = false)
189  : SourceRange(R), isPoint(isP) {}
190  PathDiagnosticRange() = default;
191 };
192 
194  llvm::PointerUnion<const LocationContext *, AnalysisDeclContext *>;
195 
197 private:
198  enum Kind { RangeK, SingleLocK, StmtK, DeclK } K = SingleLocK;
199 
200  const Stmt *S = nullptr;
201  const Decl *D = nullptr;
202  const SourceManager *SM = nullptr;
205 
207  : K(kind), SM(&sm), Loc(genLocation(L)), Range(genRange()) {}
208 
209  FullSourceLoc genLocation(
211  LocationOrAnalysisDeclContext LAC = (AnalysisDeclContext *)nullptr) const;
212 
213  PathDiagnosticRange genRange(
214  LocationOrAnalysisDeclContext LAC = (AnalysisDeclContext *)nullptr) const;
215 
216 public:
217  /// Create an invalid location.
218  PathDiagnosticLocation() = default;
219 
220  /// Create a location corresponding to the given statement.
223  : K(s->getBeginLoc().isValid() ? StmtK : SingleLocK),
224  S(K == StmtK ? s : nullptr), SM(&sm),
225  Loc(genLocation(SourceLocation(), lac)), Range(genRange(lac)) {
226  assert(K == SingleLocK || S);
227  assert(K == SingleLocK || Loc.isValid());
228  assert(K == SingleLocK || Range.isValid());
229  }
230 
231  /// Create a location corresponding to the given declaration.
233  : K(DeclK), D(d), SM(&sm), Loc(genLocation()), Range(genRange()) {
234  assert(D);
235  assert(Loc.isValid());
236  assert(Range.isValid());
237  }
238 
239  /// Create a location at an explicit offset in the source.
240  ///
241  /// This should only be used if there are no more appropriate constructors.
243  : SM(&sm), Loc(loc, sm), Range(genRange()) {
244  assert(Loc.isValid());
245  assert(Range.isValid());
246  }
247 
248  /// Create a location corresponding to the given declaration.
250  const SourceManager &SM) {
251  return PathDiagnosticLocation(D, SM);
252  }
253 
254  /// Create a location for the beginning of the declaration.
255  static PathDiagnosticLocation createBegin(const Decl *D,
256  const SourceManager &SM);
257 
258  /// Create a location for the beginning of the declaration.
259  /// The third argument is ignored, useful for generic treatment
260  /// of statements and declarations.
262  createBegin(const Decl *D, const SourceManager &SM,
263  const LocationOrAnalysisDeclContext LAC) {
264  return createBegin(D, SM);
265  }
266 
267  /// Create a location for the beginning of the statement.
268  static PathDiagnosticLocation createBegin(const Stmt *S,
269  const SourceManager &SM,
271 
272  /// Create a location for the end of the statement.
273  ///
274  /// If the statement is a CompoundStatement, the location will point to the
275  /// closing brace instead of following it.
276  static PathDiagnosticLocation createEnd(const Stmt *S,
277  const SourceManager &SM,
279 
280  /// Create the location for the operator of the binary expression.
281  /// Assumes the statement has a valid location.
283  const SourceManager &SM);
285  const ConditionalOperator *CO,
286  const SourceManager &SM);
287 
288  /// For member expressions, return the location of the '.' or '->'.
289  /// Assumes the statement has a valid location.
291  const SourceManager &SM);
292 
293  /// Create a location for the beginning of the compound statement.
294  /// Assumes the statement has a valid location.
296  const SourceManager &SM);
297 
298  /// Create a location for the end of the compound statement.
299  /// Assumes the statement has a valid location.
301  const SourceManager &SM);
302 
303  /// Create a location for the beginning of the enclosing declaration body.
304  /// Defaults to the beginning of the first statement in the declaration body.
306  const SourceManager &SM);
307 
308  /// Constructs a location for the end of the enclosing declaration body.
309  /// Defaults to the end of brace.
311  const SourceManager &SM);
312 
313  /// Create a location corresponding to the given valid ProgramPoint.
315  const SourceManager &SMng);
316 
317  /// Convert the given location into a single kind location.
319  const PathDiagnosticLocation &PDL);
320 
321  /// Construct a source location that corresponds to either the beginning
322  /// or the end of the given statement, or a nearby valid source location
323  /// if the statement does not have a valid source location of its own.
324  static SourceLocation
326  bool UseEndOfStatement = false);
327 
328  bool operator==(const PathDiagnosticLocation &X) const {
329  return K == X.K && Loc == X.Loc && Range == X.Range;
330  }
331 
332  bool operator!=(const PathDiagnosticLocation &X) const {
333  return !(*this == X);
334  }
335 
336  bool isValid() const {
337  return SM != nullptr;
338  }
339 
341  return Loc;
342  }
343 
345  return Range;
346  }
347 
348  const Stmt *asStmt() const { assert(isValid()); return S; }
349  const Stmt *getStmtOrNull() const {
350  if (!isValid())
351  return nullptr;
352  return asStmt();
353  }
354 
355  const Decl *asDecl() const { assert(isValid()); return D; }
356 
357  bool hasRange() const { return K == StmtK || K == RangeK || K == DeclK; }
358 
359  bool hasValidLocation() const { return asLocation().isValid(); }
360 
361  void invalidate() {
362  *this = PathDiagnosticLocation();
363  }
364 
365  void flatten();
366 
367  const SourceManager& getManager() const { assert(isValid()); return *SM; }
368 
369  void Profile(llvm::FoldingSetNodeID &ID) const;
370 
371  void dump() const;
372 };
373 
375 private:
376  PathDiagnosticLocation Start, End;
377 
378 public:
380  const PathDiagnosticLocation &end)
381  : Start(start), End(end) {}
382 
383  const PathDiagnosticLocation &getStart() const { return Start; }
384  const PathDiagnosticLocation &getEnd() const { return End; }
385 
386  void setStart(const PathDiagnosticLocation &L) { Start = L; }
387  void setEnd(const PathDiagnosticLocation &L) { End = L; }
388 
389  void flatten() {
390  Start.flatten();
391  End.flatten();
392  }
393 
394  void Profile(llvm::FoldingSetNodeID &ID) const {
395  Start.Profile(ID);
396  End.Profile(ID);
397  }
398 };
399 
400 //===----------------------------------------------------------------------===//
401 // Path "pieces" for path-sensitive diagnostics.
402 //===----------------------------------------------------------------------===//
403 
404 class PathDiagnosticPiece: public llvm::FoldingSetNode {
405 public:
408 
409 private:
410  const std::string str;
411  const Kind kind;
412  const DisplayHint Hint;
413 
414  /// In the containing bug report, this piece is the last piece from
415  /// the main source file.
416  bool LastInMainSourceFile = false;
417 
418  /// A constant string that can be used to tag the PathDiagnosticPiece,
419  /// typically with the identification of the creator. The actual pointer
420  /// value is meant to be an identifier; the string itself is useful for
421  /// debugging.
422  StringRef Tag;
423 
424  std::vector<SourceRange> ranges;
425  std::vector<FixItHint> fixits;
426 
427 protected:
428  PathDiagnosticPiece(StringRef s, Kind k, DisplayHint hint = Below);
430 
431 public:
432  PathDiagnosticPiece() = delete;
433  PathDiagnosticPiece(const PathDiagnosticPiece &) = delete;
435  virtual ~PathDiagnosticPiece();
436 
437  StringRef getString() const { return str; }
438 
439  /// Tag this PathDiagnosticPiece with the given C-string.
440  void setTag(const char *tag) { Tag = tag; }
441 
442  /// Return the opaque tag (if any) on the PathDiagnosticPiece.
443  const void *getTag() const { return Tag.data(); }
444 
445  /// Return the string representation of the tag. This is useful
446  /// for debugging.
447  StringRef getTagStr() const { return Tag; }
448 
449  /// getDisplayHint - Return a hint indicating where the diagnostic should
450  /// be displayed by the PathDiagnosticConsumer.
451  DisplayHint getDisplayHint() const { return Hint; }
452 
453  virtual PathDiagnosticLocation getLocation() const = 0;
454  virtual void flattenLocations() = 0;
455 
456  Kind getKind() const { return kind; }
457 
459  if (!R.isValid())
460  return;
461  ranges.push_back(R);
462  }
463 
465  if (!B.isValid() || !E.isValid())
466  return;
467  ranges.push_back(SourceRange(B,E));
468  }
469 
470  void addFixit(FixItHint F) {
471  fixits.push_back(F);
472  }
473 
474  /// Return the SourceRanges associated with this PathDiagnosticPiece.
475  ArrayRef<SourceRange> getRanges() const { return ranges; }
476 
477  /// Return the fix-it hints associated with this PathDiagnosticPiece.
478  ArrayRef<FixItHint> getFixits() const { return fixits; }
479 
480  virtual void Profile(llvm::FoldingSetNodeID &ID) const;
481 
483  LastInMainSourceFile = true;
484  }
485 
486  bool isLastInMainSourceFile() const {
487  return LastInMainSourceFile;
488  }
489 
490  virtual void dump() const = 0;
491 };
492 
493 using PathDiagnosticPieceRef = std::shared_ptr<PathDiagnosticPiece>;
494 
495 class PathPieces : public std::list<PathDiagnosticPieceRef> {
496  void flattenTo(PathPieces &Primary, PathPieces &Current,
497  bool ShouldFlattenMacros) const;
498 
499 public:
500  PathPieces flatten(bool ShouldFlattenMacros) const {
501  PathPieces Result;
502  flattenTo(Result, Result, ShouldFlattenMacros);
503  return Result;
504  }
505 
506  void dump() const;
507 };
508 
510 private:
512 
513 public:
515  StringRef s,
517  bool addPosRange = true)
518  : PathDiagnosticPiece(s, k), Pos(pos) {
519  assert(Pos.isValid() && Pos.hasValidLocation() &&
520  "PathDiagnosticSpotPiece's must have a valid location.");
521  if (addPosRange && Pos.hasRange()) addRange(Pos.asRange());
522  }
523 
524  PathDiagnosticLocation getLocation() const override { return Pos; }
525  void flattenLocations() override { Pos.flatten(); }
526 
527  void Profile(llvm::FoldingSetNodeID &ID) const override;
528 
529  static bool classof(const PathDiagnosticPiece *P) {
530  return P->getKind() == Event || P->getKind() == Macro ||
531  P->getKind() == Note || P->getKind() == PopUp;
532  }
533 };
534 
536  Optional<bool> IsPrunable;
537 
538 public:
540  StringRef s, bool addPosRange = true)
541  : PathDiagnosticSpotPiece(pos, s, Event, addPosRange) {}
542  ~PathDiagnosticEventPiece() override;
543 
544  /// Mark the diagnostic piece as being potentially prunable. This
545  /// flag may have been previously set, at which point it will not
546  /// be reset unless one specifies to do so.
547  void setPrunable(bool isPrunable, bool override = false) {
548  if (IsPrunable.hasValue() && !override)
549  return;
550  IsPrunable = isPrunable;
551  }
552 
553  /// Return true if the diagnostic piece is prunable.
554  bool isPrunable() const {
555  return IsPrunable.hasValue() ? IsPrunable.getValue() : false;
556  }
557 
558  void dump() const override;
559 
560  static bool classof(const PathDiagnosticPiece *P) {
561  return P->getKind() == Event;
562  }
563 };
564 
566  const Decl *Caller;
567  const Decl *Callee = nullptr;
568 
569  // Flag signifying that this diagnostic has only call enter and no matching
570  // call exit.
571  bool NoExit;
572 
573  // Flag signifying that the callee function is an Objective-C autosynthesized
574  // property getter or setter.
575  bool IsCalleeAnAutosynthesizedPropertyAccessor = false;
576 
577  // The custom string, which should appear after the call Return Diagnostic.
578  // TODO: Should we allow multiple diagnostics?
579  std::string CallStackMessage;
580 
581  PathDiagnosticCallPiece(const Decl *callerD,
582  const PathDiagnosticLocation &callReturnPos)
583  : PathDiagnosticPiece(Call), Caller(callerD), NoExit(false),
584  callReturn(callReturnPos) {}
585  PathDiagnosticCallPiece(PathPieces &oldPath, const Decl *caller)
586  : PathDiagnosticPiece(Call), Caller(caller), NoExit(true),
587  path(oldPath) {}
588 
589 public:
594 
595  ~PathDiagnosticCallPiece() override;
596 
597  const Decl *getCaller() const { return Caller; }
598 
599  const Decl *getCallee() const { return Callee; }
600  void setCallee(const CallEnter &CE, const SourceManager &SM);
601 
602  bool hasCallStackMessage() { return !CallStackMessage.empty(); }
603  void setCallStackMessage(StringRef st) { CallStackMessage = std::string(st); }
604 
605  PathDiagnosticLocation getLocation() const override { return callEnter; }
606 
607  std::shared_ptr<PathDiagnosticEventPiece> getCallEnterEvent() const;
608  std::shared_ptr<PathDiagnosticEventPiece>
610  std::shared_ptr<PathDiagnosticEventPiece> getCallExitEvent() const;
611 
612  void flattenLocations() override {
613  callEnter.flatten();
615  for (const auto &I : path)
616  I->flattenLocations();
617  }
618 
619  static std::shared_ptr<PathDiagnosticCallPiece>
620  construct(const CallExitEnd &CE,
621  const SourceManager &SM);
622 
624  const Decl *caller);
625 
626  void dump() const override;
627 
628  void Profile(llvm::FoldingSetNodeID &ID) const override;
629 
630  static bool classof(const PathDiagnosticPiece *P) {
631  return P->getKind() == Call;
632  }
633 };
634 
636  std::vector<PathDiagnosticLocationPair> LPairs;
637 
638 public:
640  const PathDiagnosticLocation &endPos,
641  StringRef s)
643  LPairs.push_back(PathDiagnosticLocationPair(startPos, endPos));
644  }
645 
647  const PathDiagnosticLocation &endPos)
649  LPairs.push_back(PathDiagnosticLocationPair(startPos, endPos));
650  }
651 
653 
655  assert(!LPairs.empty() &&
656  "PathDiagnosticControlFlowPiece needs at least one location.");
657  return LPairs[0].getStart();
658  }
659 
661  assert(!LPairs.empty() &&
662  "PathDiagnosticControlFlowPiece needs at least one location.");
663  return LPairs[0].getEnd();
664  }
665 
667  LPairs[0].setStart(L);
668  }
669 
671  LPairs[0].setEnd(L);
672  }
673 
674  void push_back(const PathDiagnosticLocationPair &X) { LPairs.push_back(X); }
675 
677  return getStartLocation();
678  }
679 
680  using iterator = std::vector<PathDiagnosticLocationPair>::iterator;
681 
682  iterator begin() { return LPairs.begin(); }
683  iterator end() { return LPairs.end(); }
684 
685  void flattenLocations() override {
686  for (auto &I : *this)
687  I.flatten();
688  }
689 
690  using const_iterator =
691  std::vector<PathDiagnosticLocationPair>::const_iterator;
692 
693  const_iterator begin() const { return LPairs.begin(); }
694  const_iterator end() const { return LPairs.end(); }
695 
696  static bool classof(const PathDiagnosticPiece *P) {
697  return P->getKind() == ControlFlow;
698  }
699 
700  void dump() const override;
701 
702  void Profile(llvm::FoldingSetNodeID &ID) const override;
703 };
704 
706 public:
708  : PathDiagnosticSpotPiece(pos, "", Macro) {}
709  ~PathDiagnosticMacroPiece() override;
710 
712 
713  void flattenLocations() override {
715  for (const auto &I : subPieces)
716  I->flattenLocations();
717  }
718 
719  static bool classof(const PathDiagnosticPiece *P) {
720  return P->getKind() == Macro;
721  }
722 
723  void dump() const override;
724 
725  void Profile(llvm::FoldingSetNodeID &ID) const override;
726 };
727 
729 public:
731  bool AddPosRange = true)
732  : PathDiagnosticSpotPiece(Pos, S, Note, AddPosRange) {}
733  ~PathDiagnosticNotePiece() override;
734 
735  static bool classof(const PathDiagnosticPiece *P) {
736  return P->getKind() == Note;
737  }
738 
739  void dump() const override;
740 
741  void Profile(llvm::FoldingSetNodeID &ID) const override;
742 };
743 
745 public:
747  bool AddPosRange = true)
748  : PathDiagnosticSpotPiece(Pos, S, PopUp, AddPosRange) {}
749  ~PathDiagnosticPopUpPiece() override;
750 
751  static bool classof(const PathDiagnosticPiece *P) {
752  return P->getKind() == PopUp;
753  }
754 
755  void dump() const override;
756 
757  void Profile(llvm::FoldingSetNodeID &ID) const override;
758 };
759 
760 /// File IDs mapped to sets of line numbers.
761 using FilesToLineNumsMap = std::map<FileID, std::set<unsigned>>;
762 
763 /// PathDiagnostic - PathDiagnostic objects represent a single path-sensitive
764 /// diagnostic. It represents an ordered-collection of PathDiagnosticPieces,
765 /// each which represent the pieces of the path.
766 class PathDiagnostic : public llvm::FoldingSetNode {
767  std::string CheckerName;
768  const Decl *DeclWithIssue;
770  std::string VerboseDesc;
771  std::string ShortDesc;
772  std::string Category;
773  std::deque<std::string> OtherDesc;
774 
775  /// Loc The location of the path diagnostic report.
777 
778  PathPieces pathImpl;
780 
781  /// Important bug uniqueing location.
782  /// The location info is useful to differentiate between bugs.
783  PathDiagnosticLocation UniqueingLoc;
784  const Decl *UniqueingDecl;
785 
786  /// Lines executed in the path.
787  std::unique_ptr<FilesToLineNumsMap> ExecutedLines;
788 
789 public:
790  PathDiagnostic() = delete;
791  PathDiagnostic(StringRef CheckerName, const Decl *DeclWithIssue,
792  StringRef bugtype, StringRef verboseDesc, StringRef shortDesc,
793  StringRef category, PathDiagnosticLocation LocationToUnique,
794  const Decl *DeclToUnique,
795  std::unique_ptr<FilesToLineNumsMap> ExecutedLines);
796  ~PathDiagnostic();
797 
798  const PathPieces &path;
799 
800  /// Return the path currently used by builders for constructing the
801  /// PathDiagnostic.
803  if (pathStack.empty())
804  return pathImpl;
805  return *pathStack.back();
806  }
807 
808  /// Return a mutable version of 'path'.
810  return pathImpl;
811  }
812 
813  /// Return the unrolled size of the path.
814  unsigned full_size();
815 
816  void pushActivePath(PathPieces *p) { pathStack.push_back(p); }
817  void popActivePath() { if (!pathStack.empty()) pathStack.pop_back(); }
818 
819  bool isWithinCall() const { return !pathStack.empty(); }
820 
822  assert(!Loc.isValid() && "End location already set!");
823  Loc = EndPiece->getLocation();
824  assert(Loc.isValid() && "Invalid location for end-of-path piece");
825  getActivePath().push_back(std::move(EndPiece));
826  }
827 
828  void appendToDesc(StringRef S) {
829  if (!ShortDesc.empty())
830  ShortDesc += S;
831  VerboseDesc += S;
832  }
833 
834  StringRef getVerboseDescription() const { return VerboseDesc; }
835 
836  StringRef getShortDescription() const {
837  return ShortDesc.empty() ? VerboseDesc : ShortDesc;
838  }
839 
840  StringRef getCheckerName() const { return CheckerName; }
841  StringRef getBugType() const { return BugType; }
842  StringRef getCategory() const { return Category; }
843 
844  using meta_iterator = std::deque<std::string>::const_iterator;
845 
846  meta_iterator meta_begin() const { return OtherDesc.begin(); }
847  meta_iterator meta_end() const { return OtherDesc.end(); }
848  void addMeta(StringRef s) { OtherDesc.push_back(std::string(s)); }
849 
851  return *ExecutedLines;
852  }
853 
855  return *ExecutedLines;
856  }
857 
858  /// Return the semantic context where an issue occurred. If the
859  /// issue occurs along a path, this represents the "central" area
860  /// where the bug manifests.
861  const Decl *getDeclWithIssue() const { return DeclWithIssue; }
862 
863  void setDeclWithIssue(const Decl *D) {
864  DeclWithIssue = D;
865  }
866 
868  return Loc;
869  }
870 
872  Loc = NewLoc;
873  }
874 
875  /// Get the location on which the report should be uniqued.
877  return UniqueingLoc;
878  }
879 
880  /// Get the declaration containing the uniqueing location.
881  const Decl *getUniqueingDecl() const {
882  return UniqueingDecl;
883  }
884 
886  Loc.flatten();
887  for (const auto &I : pathImpl)
888  I->flattenLocations();
889  }
890 
891  /// Profiles the diagnostic, independent of the path it references.
892  ///
893  /// This can be used to merge diagnostics that refer to the same issue
894  /// along different paths.
895  void Profile(llvm::FoldingSetNodeID &ID) const;
896 
897  /// Profiles the diagnostic, including its path.
898  ///
899  /// Two diagnostics with the same issue along different paths will generate
900  /// different profiles.
901  void FullProfile(llvm::FoldingSetNodeID &ID) const;
902 };
903 
904 } // namespace ento
905 } // namespace clang
906 
907 #endif // LLVM_CLANG_STATICANALYZER_CORE_BUGREPORTER_PATHDIAGNOSTIC_H
clang::ento::PathDiagnosticCallPiece::setCallStackMessage
void setCallStackMessage(StringRef st)
Definition: PathDiagnostic.h:603
clang::ento::PathDiagnostic::getBugType
StringRef getBugType() const
Definition: PathDiagnostic.h:841
clang::ento::PathDiagnosticConsumerOptions::ShouldDisplayDiagnosticName
bool ShouldDisplayDiagnosticName
Whether the consumer should present the name of the entity that emitted the diagnostic (eg....
Definition: PathDiagnostic.h:97
clang::ento::PathDiagnosticConsumerOptions
These options tweak the behavior of path diangostic consumers.
Definition: PathDiagnostic.h:63
clang::ento::PathDiagnosticConsumer::PDFileEntry
Definition: PathDiagnostic.h:102
clang::ento::PathDiagnosticMacroPiece::classof
static bool classof(const PathDiagnosticPiece *P)
Definition: PathDiagnostic.h:719
clang::ento::PathDiagnosticPiece::Event
@ Event
Definition: PathDiagnostic.h:406
clang::ento::PathDiagnosticEventPiece::setPrunable
void setPrunable(bool isPrunable, bool override=false)
Mark the diagnostic piece as being potentially prunable.
Definition: PathDiagnostic.h:547
clang::ento::PathDiagnosticConsumer::FilesMade::~FilesMade
~FilesMade()
Definition: PathDiagnostic.cpp:436
clang::ento::PathDiagnosticConsumer::HandlePathDiagnostic
void HandlePathDiagnostic(std::unique_ptr< PathDiagnostic > D)
Definition: PathDiagnostic.cpp:141
clang::ento::PathDiagnosticControlFlowPiece::push_back
void push_back(const PathDiagnosticLocationPair &X)
Definition: PathDiagnostic.h:674
clang::ento::PathDiagnosticPiece::getDisplayHint
DisplayHint getDisplayHint() const
getDisplayHint - Return a hint indicating where the diagnostic should be displayed by the PathDiagnos...
Definition: PathDiagnostic.h:451
clang::ento::PathDiagnostic::getExecutedLines
const FilesToLineNumsMap & getExecutedLines() const
Definition: PathDiagnostic.h:850
clang::ento::PathDiagnostic::PathDiagnostic
PathDiagnostic()=delete
clang::ento::PathDiagnosticCallPiece::classof
static bool classof(const PathDiagnosticPiece *P)
Definition: PathDiagnostic.h:630
clang::ento::PathDiagnostic::getMutablePieces
PathPieces & getMutablePieces()
Return a mutable version of 'path'.
Definition: PathDiagnostic.h:809
clang::ento::PathDiagnosticLocation
Definition: PathDiagnostic.h:196
clang::ento::PathDiagnosticConsumer::Minimal
@ Minimal
Used for HTML, SARIF, and text output.
Definition: PathDiagnostic.h:155
clang::ento::PathDiagnosticControlFlowPiece::~PathDiagnosticControlFlowPiece
~PathDiagnosticControlFlowPiece() override
clang::ento::PathDiagnostic::full_size
unsigned full_size()
Return the unrolled size of the path.
Definition: PathDiagnostic.cpp:1075
clang::ento::PathDiagnosticConsumer::supportsLogicalOpControlFlow
virtual bool supportsLogicalOpControlFlow() const
Definition: PathDiagnostic.h:169
clang::ento::PathDiagnosticConsumer::FlushDiagnosticsImpl
virtual void FlushDiagnosticsImpl(std::vector< const PathDiagnostic * > &Diags, FilesMade *filesMade)=0
clang::LocationContext
It wraps the AnalysisDeclContext to represent both the call stack with the help of StackFrameContext ...
Definition: AnalysisDeclContext.h:213
clang::ento::PathDiagnosticPiece::isLastInMainSourceFile
bool isLastInMainSourceFile() const
Definition: PathDiagnostic.h:486
clang::FullSourceLoc
A SourceLocation and its associated SourceManager.
Definition: SourceLocation.h:366
clang::ento::PathDiagnosticPopUpPiece::Profile
void Profile(llvm::FoldingSetNodeID &ID) const override
Definition: PathDiagnostic.cpp:1130
clang::SourceRange
A trivial tuple used to represent a source range.
Definition: SourceLocation.h:212
string
string(SUBSTRING ${CMAKE_CURRENT_BINARY_DIR} 0 ${PATH_LIB_START} PATH_HEAD) string(SUBSTRING $
Definition: CMakeLists.txt:22
clang::ento::PathDiagnostic::popActivePath
void popActivePath()
Definition: PathDiagnostic.h:817
clang::ento::PathDiagnosticCallPiece::hasCallStackMessage
bool hasCallStackMessage()
Definition: PathDiagnostic.h:602
clang::ento::PathDiagnosticPiece::Below
@ Below
Definition: PathDiagnostic.h:407
clang::ento::PathDiagnosticPieceRef
std::shared_ptr< PathDiagnosticPiece > PathDiagnosticPieceRef
Definition: PathDiagnostic.h:493
clang::ento::PathDiagnosticPiece::addFixit
void addFixit(FixItHint F)
Definition: PathDiagnostic.h:470
clang::ento::PathDiagnosticCallPiece::getLocation
PathDiagnosticLocation getLocation() const override
Definition: PathDiagnostic.h:605
clang::ento::PathDiagnosticLocationPair::setEnd
void setEnd(const PathDiagnosticLocation &L)
Definition: PathDiagnostic.h:387
clang::ento::PathDiagnostic::~PathDiagnostic
~PathDiagnostic()
clang::ento::PathDiagnosticSpotPiece::classof
static bool classof(const PathDiagnosticPiece *P)
Definition: PathDiagnostic.h:529
AnalysisDeclContext.h
clang::ento::PathDiagnosticLocation::createEnd
static PathDiagnosticLocation createEnd(const Stmt *S, const SourceManager &SM, const LocationOrAnalysisDeclContext LAC)
Create a location for the end of the statement.
Definition: PathDiagnostic.cpp:594
llvm::SmallVector
Definition: LLVM.h:38
clang::ento::PathDiagnosticEventPiece::dump
void dump() const override
Definition: PathDiagnostic.cpp:1170
clang::SourceLocation
Encodes a location in the source.
Definition: SourceLocation.h:89
clang::ento::PathDiagnosticLocation::getValidSourceLocation
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...
Definition: PathDiagnostic.cpp:478
clang::ento::PathDiagnosticRange::PathDiagnosticRange
PathDiagnosticRange(SourceRange R, bool isP=false)
Definition: PathDiagnostic.h:188
clang::ento::PathDiagnosticLocationPair::Profile
void Profile(llvm::FoldingSetNodeID &ID) const
Definition: PathDiagnostic.h:394
clang::ento::PathDiagnosticLocation::flatten
void flatten()
Definition: PathDiagnostic.cpp:829
clang::ento::PathDiagnosticPiece::~PathDiagnosticPiece
virtual ~PathDiagnosticPiece()
clang::ento::PathDiagnosticNotePiece::classof
static bool classof(const PathDiagnosticPiece *P)
Definition: PathDiagnostic.h:735
clang::ento::PathDiagnostic::getCategory
StringRef getCategory() const
Definition: PathDiagnostic.h:842
clang::ento::PathDiagnosticLocation::createDeclBegin
static PathDiagnosticLocation createDeclBegin(const LocationContext *LC, const SourceManager &SM)
Create a location for the beginning of the enclosing declaration body.
Definition: PathDiagnostic.cpp:645
clang::ento::PathDiagnostic::getShortDescription
StringRef getShortDescription() const
Definition: PathDiagnostic.h:836
clang::ento::PathDiagnosticPopUpPiece::~PathDiagnosticPopUpPiece
~PathDiagnosticPopUpPiece() override
clang::ento::PathDiagnosticConsumer::FilesMade::addDiagnostic
void addDiagnostic(const PathDiagnostic &PD, StringRef ConsumerName, StringRef fileName)
Definition: PathDiagnostic.cpp:441
clang::ento::PathDiagnosticPiece::getLocation
virtual PathDiagnosticLocation getLocation() const =0
clang::ento::PathDiagnosticControlFlowPiece
Definition: PathDiagnostic.h:635
clang::AnalysisDeclContext
AnalysisDeclContext contains the context data for the function, method or block under analysis.
Definition: AnalysisDeclContext.h:72
clang::ento::PathDiagnosticControlFlowPiece::classof
static bool classof(const PathDiagnosticPiece *P)
Definition: PathDiagnostic.h:696
clang::ento::PathDiagnosticMacroPiece::subPieces
PathPieces subPieces
Definition: PathDiagnostic.h:711
clang::ento::PathDiagnosticPopUpPiece
Definition: PathDiagnostic.h:744
clang::ento::PathDiagnosticControlFlowPiece::const_iterator
std::vector< PathDiagnosticLocationPair >::const_iterator const_iterator
Definition: PathDiagnostic.h:691
clang::ento::PathDiagnosticLocation::createSingleLocation
static PathDiagnosticLocation createSingleLocation(const PathDiagnosticLocation &PDL)
Convert the given location into a single kind location.
Definition: PathDiagnostic.cpp:736
clang::SourceRange::isValid
bool isValid() const
Definition: SourceLocation.h:227
clang::ento::PathDiagnosticNotePiece::~PathDiagnosticNotePiece
~PathDiagnosticNotePiece() override
clang::ento::PathDiagnosticLocation::createMemberLoc
static PathDiagnosticLocation createMemberLoc(const MemberExpr *ME, const SourceManager &SM)
For member expressions, return the location of the '.
Definition: PathDiagnostic.cpp:617
clang::ento::PathDiagnosticCallPiece::callEnter
PathDiagnosticLocation callEnter
Definition: PathDiagnostic.h:590
clang::ento::PathDiagnosticPopUpPiece::classof
static bool classof(const PathDiagnosticPiece *P)
Definition: PathDiagnostic.h:751
llvm::Optional< bool >
clang::ento::PathDiagnostic::setDeclWithIssue
void setDeclWithIssue(const Decl *D)
Definition: PathDiagnostic.h:863
clang::ento::PathDiagnosticNotePiece::PathDiagnosticNotePiece
PathDiagnosticNotePiece(const PathDiagnosticLocation &Pos, StringRef S, bool AddPosRange=true)
Definition: PathDiagnostic.h:730
clang::ento::PathDiagnosticLocationPair::setStart
void setStart(const PathDiagnosticLocation &L)
Definition: PathDiagnostic.h:386
clang::ento::PathDiagnosticNotePiece::dump
void dump() const override
Definition: PathDiagnostic.cpp:1189
clang::ento::PathDiagnostic::meta_begin
meta_iterator meta_begin() const
Definition: PathDiagnostic.h:846
clang::ento::PathDiagnosticControlFlowPiece::getEndLocation
PathDiagnosticLocation getEndLocation() const
Definition: PathDiagnostic.h:660
clang::tooling::X
static ToolExecutorPluginRegistry::Add< AllTUsToolExecutorPlugin > X("all-TUs", "Runs FrontendActions on all TUs in the compilation database. " "Tool results are stored in memory.")
clang::ento::PathDiagnosticSpotPiece::flattenLocations
void flattenLocations() override
Definition: PathDiagnostic.h:525
clang::ento::PathDiagnosticPopUpPiece::dump
void dump() const override
Definition: PathDiagnostic.cpp:1196
clang::ento::PathDiagnosticPopUpPiece::PathDiagnosticPopUpPiece
PathDiagnosticPopUpPiece(const PathDiagnosticLocation &Pos, StringRef S, bool AddPosRange=true)
Definition: PathDiagnostic.h:746
clang::ento::PathDiagnosticRange::PathDiagnosticRange
PathDiagnosticRange()=default
clang::ento::PathDiagnosticCallPiece::getCallEnterWithinCallerEvent
std::shared_ptr< PathDiagnosticEventPiece > getCallEnterWithinCallerEvent() const
Definition: PathDiagnostic.cpp:1021
clang::SourceManager
This class handles loading and caching of source files into memory.
Definition: SourceManager.h:624
clang::ento::PathDiagnosticConsumer::PDFileEntry::NodeID
const llvm::FoldingSetNodeID NodeID
A precomputed hash tag used for uniquing PDFileEntry objects.
Definition: PathDiagnostic.h:112
clang::ento::PathDiagnosticMacroPiece
Definition: PathDiagnostic.h:705
clang::ento::PathDiagnosticLocation::hasValidLocation
bool hasValidLocation() const
Definition: PathDiagnostic.h:359
clang::ConditionalOperator
ConditionalOperator - The ?: ternary operator.
Definition: Expr.h:4065
clang::ento::PathDiagnostic::appendToDesc
void appendToDesc(StringRef S)
Definition: PathDiagnostic.h:828
clang::ento::PathDiagnosticLocation::operator==
bool operator==(const PathDiagnosticLocation &X) const
Definition: PathDiagnostic.h:328
clang::FixItHint
Annotates a diagnostic with some code that should be inserted, removed, or replaced to fix the proble...
Definition: Diagnostic.h:70
clang::CodeGen::AlignmentSource::Decl
@ Decl
The l-value was an access to a declared entity or something equivalently strong, like the address of ...
clang::ento::PathDiagnosticConsumerOptions::ShouldApplyFixIts
bool ShouldApplyFixIts
Whether the consumer should attempt to rewrite the source file with fix-it hints attached to the diag...
Definition: PathDiagnostic.h:93
clang::ento::PathDiagnosticPiece::Call
@ Call
Definition: PathDiagnostic.h:406
clang::ento::PathDiagnosticNotePiece::Profile
void Profile(llvm::FoldingSetNodeID &ID) const override
Definition: PathDiagnostic.cpp:1126
clang::ento::PathDiagnosticLocation::PathDiagnosticLocation
PathDiagnosticLocation()=default
Create an invalid location.
clang::ento::PathDiagnosticPiece::PathDiagnosticPiece
PathDiagnosticPiece()=delete
clang::ento::PathDiagnosticControlFlowPiece::iterator
std::vector< PathDiagnosticLocationPair >::iterator iterator
Definition: PathDiagnostic.h:680
clang::CompoundStmt
CompoundStmt - This represents a group of statements like { stmt stmt }.
Definition: Stmt.h:1398
clang::ento::PathDiagnostic::getDeclWithIssue
const Decl * getDeclWithIssue() const
Return the semantic context where an issue occurred.
Definition: PathDiagnostic.h:861
clang::ento::PathDiagnosticConsumer::Diags
llvm::FoldingSet< PathDiagnostic > Diags
Definition: PathDiagnostic.h:177
clang::ento::PathDiagnosticControlFlowPiece::begin
iterator begin()
Definition: PathDiagnostic.h:682
clang::ento::Range
A Range represents the closed range [from, to].
Definition: RangedConstraintManager.h:29
clang::ento::PathDiagnosticControlFlowPiece::dump
void dump() const override
Definition: PathDiagnostic.cpp:1177
clang::BinaryOperator
A builtin binary operation expression such as "x + y" or "x <= y".
Definition: Expr.h:3727
clang::ento::PathDiagnosticLocation::create
static PathDiagnosticLocation create(const Decl *D, const SourceManager &SM)
Create a location corresponding to the given declaration.
Definition: PathDiagnostic.h:249
clang::ento::PathDiagnosticConsumer::FlushDiagnostics
void FlushDiagnostics(FilesMade *FilesMade)
Definition: PathDiagnostic.cpp:403
clang::ento::PathDiagnosticCallPiece::callReturn
PathDiagnosticLocation callReturn
Definition: PathDiagnostic.h:592
clang::ento::PathDiagnosticConsumer::FilesMade
Definition: PathDiagnostic.h:118
clang::ento::PathDiagnosticConsumer::~PathDiagnosticConsumer
virtual ~PathDiagnosticConsumer()
Definition: PathDiagnostic.cpp:135
clang::ento::PathDiagnosticLocation::PathDiagnosticLocation
PathDiagnosticLocation(const Decl *d, const SourceManager &sm)
Create a location corresponding to the given declaration.
Definition: PathDiagnostic.h:232
clang::ento::PathDiagnosticLocation::isValid
bool isValid() const
Definition: PathDiagnostic.h:336
clang::CallExitEnd
Represents a point when we finish the call exit sequence (for inlined call).
Definition: ProgramPoint.h:688
clang::ento::PathDiagnostic::setEndOfPath
void setEndOfPath(PathDiagnosticPieceRef EndPiece)
Definition: PathDiagnostic.h:821
clang::ento::PathDiagnosticLocation::getStmtOrNull
const Stmt * getStmtOrNull() const
Definition: PathDiagnostic.h:349
clang::ento::BugType
Definition: BugType.h:29
clang::ento::PathDiagnosticConsumerOptions::ToolInvocation
std::string ToolInvocation
Run-line of the tool that produced the diagnostic.
Definition: PathDiagnostic.h:66
clang::ento::PathDiagnosticRange
Definition: PathDiagnostic.h:184
clang::ento::PathDiagnosticLocation::createOperatorLoc
static PathDiagnosticLocation createOperatorLoc(const BinaryOperator *BO, const SourceManager &SM)
Create the location for the operator of the binary expression.
Definition: PathDiagnostic.cpp:604
clang::ento::PathDiagnosticLocation::asStmt
const Stmt * asStmt() const
Definition: PathDiagnostic.h:348
clang::ento::PathDiagnostic::getUniqueingDecl
const Decl * getUniqueingDecl() const
Get the declaration containing the uniqueing location.
Definition: PathDiagnostic.h:881
clang::ento::PathDiagnosticPiece::dump
virtual void dump() const =0
clang::ento::PathDiagnosticLocation::dump
void dump() const
Definition: PathDiagnostic.cpp:1203
clang::ento::PathDiagnosticRange::isPoint
bool isPoint
Definition: PathDiagnostic.h:186
clang::ento::LocationOrAnalysisDeclContext
llvm::PointerUnion< const LocationContext *, AnalysisDeclContext * > LocationOrAnalysisDeclContext
Definition: PathDiagnostic.h:194
clang::ento::PathDiagnosticControlFlowPiece::setStartLocation
void setStartLocation(const PathDiagnosticLocation &L)
Definition: PathDiagnostic.h:666
clang::ento::PathDiagnostic::isWithinCall
bool isWithinCall() const
Definition: PathDiagnostic.h:819
clang::ento::PathDiagnosticSpotPiece::PathDiagnosticSpotPiece
PathDiagnosticSpotPiece(const PathDiagnosticLocation &pos, StringRef s, PathDiagnosticPiece::Kind k, bool addPosRange=true)
Definition: PathDiagnostic.h:514
clang::ento::PathDiagnostic::getActivePath
PathPieces & getActivePath()
Return the path currently used by builders for constructing the PathDiagnostic.
Definition: PathDiagnostic.h:802
clang::ento::PathDiagnosticConsumer
Definition: PathDiagnostic.h:100
Category
int Category
Definition: Format.cpp:2152
clang::ento::FilesToLineNumsMap
std::map< FileID, std::set< unsigned > > FilesToLineNumsMap
File IDs mapped to sets of line numbers.
Definition: PathDiagnostic.h:761
clang::ento::PathDiagnosticConsumer::getGenerationScheme
virtual PathGenerationScheme getGenerationScheme() const
Definition: PathDiagnostic.h:161
clang::ento::PathDiagnosticControlFlowPiece::begin
const_iterator begin() const
Definition: PathDiagnostic.h:693
clang::ento::PathDiagnosticPiece::getRanges
ArrayRef< SourceRange > getRanges() const
Return the SourceRanges associated with this PathDiagnosticPiece.
Definition: PathDiagnostic.h:475
clang::ento::PathDiagnosticLocation::createDeclEnd
static PathDiagnosticLocation createDeclEnd(const LocationContext *LC, const SourceManager &SM)
Constructs a location for the end of the enclosing declaration body.
Definition: PathDiagnostic.cpp:658
clang::ento::PathDiagnostic::addMeta
void addMeta(StringRef s)
Definition: PathDiagnostic.h:848
clang::ento::PathDiagnosticConsumer::shouldAddPathEdges
bool shouldAddPathEdges() const
Definition: PathDiagnostic.h:167
clang::ento::PathDiagnosticLocation::PathDiagnosticLocation
PathDiagnosticLocation(const Stmt *s, const SourceManager &sm, LocationOrAnalysisDeclContext lac)
Create a location corresponding to the given statement.
Definition: PathDiagnostic.h:221
clang::ento::PathPieces::flatten
PathPieces flatten(bool ShouldFlattenMacros) const
Definition: PathDiagnostic.h:500
clang::ento::PathDiagnosticPiece::DisplayHint
DisplayHint
Definition: PathDiagnostic.h:407
clang::ento::PathDiagnosticCallPiece
Definition: PathDiagnostic.h:565
clang::ento::PathDiagnosticPiece::getString
StringRef getString() const
Definition: PathDiagnostic.h:437
clang::ento::PathDiagnosticLocation::PathDiagnosticLocation
PathDiagnosticLocation(SourceLocation loc, const SourceManager &sm)
Create a location at an explicit offset in the source.
Definition: PathDiagnostic.h:242
clang::ento::PathDiagnosticConsumer::FilesMade::getFiles
PDFileEntry::ConsumerFiles * getFiles(const PathDiagnostic &PD)
Definition: PathDiagnostic.cpp:464
clang::ento::PathDiagnosticConsumer::PDFileEntry::Profile
void Profile(llvm::FoldingSetNodeID &ID)
Used for profiling in the FoldingSet.
Definition: PathDiagnostic.h:115
clang::ento::PathDiagnosticLocation::asRange
PathDiagnosticRange asRange() const
Definition: PathDiagnostic.h:344
clang::ento::PathDiagnosticSpotPiece
Definition: PathDiagnostic.h:509
clang::ento::PathDiagnosticPiece::PopUp
@ PopUp
Definition: PathDiagnostic.h:406
clang::ento::Loc
Definition: SVals.h:314
clang::ento::PathDiagnostic::getCheckerName
StringRef getCheckerName() const
Definition: PathDiagnostic.h:840
clang::ento::PathDiagnosticConsumer::supportsCrossFileDiagnostics
virtual bool supportsCrossFileDiagnostics() const
Return true if the PathDiagnosticConsumer supports individual PathDiagnostics that span multiple file...
Definition: PathDiagnostic.h:173
clang::ento::PathDiagnosticMacroPiece::Profile
void Profile(llvm::FoldingSetNodeID &ID) const override
Definition: PathDiagnostic.cpp:1120
clang::ento::PathDiagnosticConsumer::getName
virtual StringRef getName() const =0
clang::ento::PathDiagnosticConsumer::shouldGenerateDiagnostics
bool shouldGenerateDiagnostics() const
Definition: PathDiagnostic.h:163
clang::ento::PathDiagnosticPiece::operator=
PathDiagnosticPiece & operator=(const PathDiagnosticPiece &)=delete
clang::ento::PathDiagnosticCallPiece::path
PathPieces path
Definition: PathDiagnostic.h:593
clang::ento::PathDiagnosticLocation::Profile
void Profile(llvm::FoldingSetNodeID &ID) const
Definition: PathDiagnostic.cpp:1085
clang::ento::PathDiagnosticEventPiece::isPrunable
bool isPrunable() const
Return true if the diagnostic piece is prunable.
Definition: PathDiagnostic.h:554
clang::ento::PathDiagnosticCallPiece::getCallee
const Decl * getCallee() const
Definition: PathDiagnostic.h:599
clang::ento::PathDiagnosticConsumer::flushed
bool flushed
Definition: PathDiagnostic.h:176
clang::ento::PathDiagnosticConsumer::PDFileEntry::files
ConsumerFiles files
A vector of <consumer,file> pairs.
Definition: PathDiagnostic.h:109
SourceLocation.h
P
StringRef P
Definition: ASTMatchersInternal.cpp:563
clang::ento::PathDiagnosticCallPiece::getCallExitEvent
std::shared_ptr< PathDiagnosticEventPiece > getCallExitEvent() const
Definition: PathDiagnostic.cpp:1040
clang::ento::PathDiagnosticConsumer::PathGenerationScheme
PathGenerationScheme
Definition: PathDiagnostic.h:150
clang::ento::PathDiagnosticMacroPiece::dump
void dump() const override
Definition: PathDiagnostic.cpp:1184
clang::ento::DefinedSVal::isValid
bool isValid() const =delete
clang::ento::PathDiagnosticConsumer::PDFileEntry::PDFileEntry
PDFileEntry(llvm::FoldingSetNodeID &NodeID)
Definition: PathDiagnostic.h:104
clang::ento::PathPieces::dump
void dump() const
Definition: PathDiagnostic.cpp:1150
clang::ento::PathDiagnosticConsumer::FilesMade::empty
bool empty() const
Definition: PathDiagnostic.h:125
clang::ento::PathDiagnosticLocation::invalidate
void invalidate()
Definition: PathDiagnostic.h:361
llvm::ArrayRef
Definition: LLVM.h:34
clang::Decl
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:89
clang::ento::PathPieces
Definition: PathDiagnostic.h:495
clang::ento::PathDiagnosticControlFlowPiece::getLocation
PathDiagnosticLocation getLocation() const override
Definition: PathDiagnostic.h:676
clang::ento::PathDiagnostic::meta_end
meta_iterator meta_end() const
Definition: PathDiagnostic.h:847
clang::ento::PathDiagnosticEventPiece::classof
static bool classof(const PathDiagnosticPiece *P)
Definition: PathDiagnostic.h:560
clang::ento::PathDiagnosticLocation::asLocation
FullSourceLoc asLocation() const
Definition: PathDiagnostic.h:340
clang::ento::PathDiagnosticLocationPair::getEnd
const PathDiagnosticLocation & getEnd() const
Definition: PathDiagnostic.h:384
clang::ento::PathDiagnostic::Profile
void Profile(llvm::FoldingSetNodeID &ID) const
Profiles the diagnostic, independent of the path it references.
Definition: PathDiagnostic.cpp:1134
LLVM.h
clang::ento::PathDiagnosticPiece::Profile
virtual void Profile(llvm::FoldingSetNodeID &ID) const
Definition: PathDiagnostic.cpp:1091
clang::ento::PathDiagnostic::getExecutedLines
FilesToLineNumsMap & getExecutedLines()
Definition: PathDiagnostic.h:854
clang::ento::PathDiagnosticEventPiece::PathDiagnosticEventPiece
PathDiagnosticEventPiece(const PathDiagnosticLocation &pos, StringRef s, bool addPosRange=true)
Definition: PathDiagnostic.h:539
clang::ento::PathDiagnostic::getUniqueingLoc
PathDiagnosticLocation getUniqueingLoc() const
Get the location on which the report should be uniqued.
Definition: PathDiagnostic.h:876
clang::ento::PathDiagnosticPiece::getKind
Kind getKind() const
Definition: PathDiagnostic.h:456
clang::ento::PathDiagnosticMacroPiece::flattenLocations
void flattenLocations() override
Definition: PathDiagnostic.h:713
clang::ento::PathDiagnosticLocation::createEndBrace
static PathDiagnosticLocation createEndBrace(const CompoundStmt *CS, const SourceManager &SM)
Create a location for the end of the compound statement.
Definition: PathDiagnostic.cpp:638
clang::ento::PathDiagnosticControlFlowPiece::flattenLocations
void flattenLocations() override
Definition: PathDiagnostic.h:685
clang::ento::PathDiagnosticControlFlowPiece::end
const_iterator end() const
Definition: PathDiagnostic.h:694
clang::ento::PathDiagnosticEventPiece
Definition: PathDiagnostic.h:535
clang::ento::PathDiagnosticPiece::addRange
void addRange(SourceRange R)
Definition: PathDiagnostic.h:458
clang::ento::PathDiagnosticPiece::Above
@ Above
Definition: PathDiagnostic.h:407
clang::ento::PathDiagnosticLocationPair::getStart
const PathDiagnosticLocation & getStart() const
Definition: PathDiagnostic.h:383
clang::ento::PathDiagnosticConsumerOptions::ShouldDisplayWarningsAsErrors
bool ShouldDisplayWarningsAsErrors
Whether the consumer should treat consumed diagnostics as hard errors.
Definition: PathDiagnostic.h:89
clang::ento::PathDiagnosticPiece::Kind
Kind
Definition: PathDiagnostic.h:406
clang::ento::PathDiagnosticLocation::createBeginBrace
static PathDiagnosticLocation createBeginBrace(const CompoundStmt *CS, const SourceManager &SM)
Create a location for the beginning of the compound statement.
Definition: PathDiagnostic.cpp:631
clang::ento::PathDiagnostic::FullProfile
void FullProfile(llvm::FoldingSetNodeID &ID) const
Profiles the diagnostic, including its path.
Definition: PathDiagnostic.cpp:1142
clang::ento::PathDiagnosticLocation::operator!=
bool operator!=(const PathDiagnosticLocation &X) const
Definition: PathDiagnostic.h:332
clang::ento::PathDiagnosticLocationPair::flatten
void flatten()
Definition: PathDiagnostic.h:389
clang::ento::PathDiagnosticConsumer::Extensive
@ Extensive
Used for plist output, used for "arrows" generation.
Definition: PathDiagnostic.h:158
clang::ento::PathDiagnosticControlFlowPiece::end
iterator end()
Definition: PathDiagnostic.h:683
clang::Builtin::ID
ID
Definition: Builtins.h:47
clang::ento::PathDiagnosticCallPiece::setCallee
void setCallee(const CallEnter &CE, const SourceManager &SM)
Definition: PathDiagnostic.cpp:868
clang::ento::PathDiagnosticLocation::createConditionalColonLoc
static PathDiagnosticLocation createConditionalColonLoc(const ConditionalOperator *CO, const SourceManager &SM)
Definition: PathDiagnostic.cpp:610
clang::ento::PathDiagnostic::flattenLocations
void flattenLocations()
Definition: PathDiagnostic.h:885
clang
Dataflow Directional Tag Classes.
Definition: CalledOnceCheck.h:17
clang::ento::PathDiagnosticPiece::addRange
void addRange(SourceLocation B, SourceLocation E)
Definition: PathDiagnostic.h:464
clang::ento::PathDiagnosticPiece::Note
@ Note
Definition: PathDiagnostic.h:406
clang::Stmt
Stmt - This represents one statement.
Definition: Stmt.h:68
clang::ento::PathDiagnosticPiece::flattenLocations
virtual void flattenLocations()=0
clang::ento::PathDiagnosticPiece::Macro
@ Macro
Definition: PathDiagnostic.h:406
clang::ento::PathDiagnosticPiece
Definition: PathDiagnostic.h:404
clang::ento::PathDiagnosticPiece::getTag
const void * getTag() const
Return the opaque tag (if any) on the PathDiagnosticPiece.
Definition: PathDiagnostic.h:443
clang::ento::PathDiagnosticLocation::createBegin
static PathDiagnosticLocation createBegin(const Decl *D, const SourceManager &SM, const LocationOrAnalysisDeclContext LAC)
Create a location for the beginning of the declaration.
Definition: PathDiagnostic.h:262
clang::SourceLocation::isValid
bool isValid() const
Return true if this is a valid SourceLocation object.
Definition: SourceLocation.h:110
clang::ento::PathDiagnosticLocation::createBegin
static PathDiagnosticLocation createBegin(const Decl *D, const SourceManager &SM)
Create a location for the beginning of the declaration.
Definition: PathDiagnostic.cpp:580
s
__device__ __2f16 float bool s
Definition: __clang_hip_libdevice_declares.h:303
clang::ento::PathDiagnosticNotePiece
Definition: PathDiagnostic.h:728
clang::ento::PathDiagnosticPiece::getFixits
ArrayRef< FixItHint > getFixits() const
Return the fix-it hints associated with this PathDiagnosticPiece.
Definition: PathDiagnostic.h:478
clang::ento::PathDiagnosticCallPiece::construct
static std::shared_ptr< PathDiagnosticCallPiece > construct(const CallExitEnd &CE, const SourceManager &SM)
Definition: PathDiagnostic.cpp:847
clang::ento::PathDiagnosticCallPiece::getCallEnterEvent
std::shared_ptr< PathDiagnosticEventPiece > getCallEnterEvent() const
Definition: PathDiagnostic.cpp:1002
clang::ento::PathDiagnostic::pushActivePath
void pushActivePath(PathPieces *p)
Definition: PathDiagnostic.h:816
clang::ento::PathDiagnosticConsumerOptions::ShouldWriteStableReportFilename
bool ShouldWriteStableReportFilename
If the consumer intends to produce multiple output files, should it use randomly generated file names...
Definition: PathDiagnostic.h:85
clang::ento::PathDiagnosticCallPiece::~PathDiagnosticCallPiece
~PathDiagnosticCallPiece() override
clang::ento::PathDiagnostic::path
const PathPieces & path
Definition: PathDiagnostic.h:798
clang::ento::PathDiagnosticSpotPiece::Profile
void Profile(llvm::FoldingSetNodeID &ID) const override
Definition: PathDiagnostic.cpp:1109
clang::ento::PathDiagnosticControlFlowPiece::PathDiagnosticControlFlowPiece
PathDiagnosticControlFlowPiece(const PathDiagnosticLocation &startPos, const PathDiagnosticLocation &endPos, StringRef s)
Definition: PathDiagnostic.h:639
clang::ento::PathDiagnostic::meta_iterator
std::deque< std::string >::const_iterator meta_iterator
Definition: PathDiagnostic.h:844
clang::ento::PathDiagnosticPiece::getTagStr
StringRef getTagStr() const
Return the string representation of the tag.
Definition: PathDiagnostic.h:447
clang::CallEnter
Represents a point when we begin processing an inlined call.
Definition: ProgramPoint.h:630
clang::ento::PathDiagnosticCallPiece::getCaller
const Decl * getCaller() const
Definition: PathDiagnostic.h:597
clang::ento::PathDiagnostic::getLocation
PathDiagnosticLocation getLocation() const
Definition: PathDiagnostic.h:867
clang::MemberExpr
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
Definition: Expr.h:3086
clang::ento::PathDiagnosticPiece::ControlFlow
@ ControlFlow
Definition: PathDiagnostic.h:406
clang::ento::PathDiagnostic
PathDiagnostic - PathDiagnostic objects represent a single path-sensitive diagnostic.
Definition: PathDiagnostic.h:766
clang::ento::PathDiagnosticConsumer::None
@ None
Only runs visitors, no output generated.
Definition: PathDiagnostic.h:152
Stmt.h
clang::ento::PathDiagnosticMacroPiece::PathDiagnosticMacroPiece
PathDiagnosticMacroPiece(const PathDiagnosticLocation &pos)
Definition: PathDiagnostic.h:707
clang::ento::PathDiagnosticCallPiece::callEnterWithin
PathDiagnosticLocation callEnterWithin
Definition: PathDiagnostic.h:591
clang::ento::PathDiagnosticPiece::setTag
void setTag(const char *tag)
Tag this PathDiagnosticPiece with the given C-string.
Definition: PathDiagnostic.h:440
clang::ento::PathDiagnosticLocation::hasRange
bool hasRange() const
Definition: PathDiagnostic.h:357
SM
#define SM(sm)
Definition: Cuda.cpp:68
clang::ento::PathDiagnosticConsumer::PathDiagnosticConsumer
PathDiagnosticConsumer()=default
clang::ento::PathDiagnostic::getVerboseDescription
StringRef getVerboseDescription() const
Definition: PathDiagnostic.h:834
clang::ento::PathDiagnosticCallPiece::dump
void dump() const override
Definition: PathDiagnostic.cpp:1159
clang::ento::PathDiagnosticEventPiece::~PathDiagnosticEventPiece
~PathDiagnosticEventPiece() override
clang::ento::PathDiagnosticPiece::setAsLastInMainSourceFile
void setAsLastInMainSourceFile()
Definition: PathDiagnostic.h:482
clang::ento::PathDiagnostic::setLocation
void setLocation(PathDiagnosticLocation NewLoc)
Definition: PathDiagnostic.h:871
clang::ento::PathDiagnosticMacroPiece::~PathDiagnosticMacroPiece
~PathDiagnosticMacroPiece() override
clang::ento::PathDiagnosticLocation::getManager
const SourceManager & getManager() const
Definition: PathDiagnostic.h:367
clang::ento::PathDiagnosticControlFlowPiece::setEndLocation
void setEndLocation(const PathDiagnosticLocation &L)
Definition: PathDiagnostic.h:670
clang::ento::PathDiagnosticSpotPiece::getLocation
PathDiagnosticLocation getLocation() const override
Definition: PathDiagnostic.h:524
clang::ento::PathDiagnosticControlFlowPiece::Profile
void Profile(llvm::FoldingSetNodeID &ID) const override
Definition: PathDiagnostic.cpp:1114
clang::ProgramPoint
Definition: ProgramPoint.h:59
clang::ento::PathDiagnosticCallPiece::flattenLocations
void flattenLocations() override
Definition: PathDiagnostic.h:612
clang::diag::kind
unsigned kind
All of the diagnostics that can be emitted by the frontend.
Definition: DiagnosticIDs.h:60
clang::ento::PathDiagnosticLocation::asDecl
const Decl * asDecl() const
Definition: PathDiagnostic.h:355
clang::ento::PathDiagnosticConsumerOptions::ShouldSerializeStats
bool ShouldSerializeStats
Whether to include LLVM statistics of the process in the diagnostic.
Definition: PathDiagnostic.h:75
clang::ento::PathDiagnosticCallPiece::Profile
void Profile(llvm::FoldingSetNodeID &ID) const override
Definition: PathDiagnostic.cpp:1103
clang::ento::PathDiagnosticControlFlowPiece::getStartLocation
PathDiagnosticLocation getStartLocation() const
Definition: PathDiagnostic.h:654
clang::ento::PathDiagnosticLocationPair
Definition: PathDiagnostic.h:374
clang::ento::PathDiagnosticControlFlowPiece::PathDiagnosticControlFlowPiece
PathDiagnosticControlFlowPiece(const PathDiagnosticLocation &startPos, const PathDiagnosticLocation &endPos)
Definition: PathDiagnostic.h:646
clang::ento::PathDiagnosticLocationPair::PathDiagnosticLocationPair
PathDiagnosticLocationPair(const PathDiagnosticLocation &start, const PathDiagnosticLocation &end)
Definition: PathDiagnostic.h:379
clang::ento::PathDiagnosticConsumerOptions::ShouldDisplayMacroExpansions
bool ShouldDisplayMacroExpansions
Whether to include additional information about macro expansions with the diagnostics,...
Definition: PathDiagnostic.h:71
clang::ento::PathDiagnosticConsumer::PDFileEntry::ConsumerFiles
std::vector< std::pair< StringRef, StringRef > > ConsumerFiles
Definition: PathDiagnostic.h:106