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