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