clang  7.0.0svn
BugReporter.h
Go to the documentation of this file.
1 //===- BugReporter.h - Generate PathDiagnostics -----------------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file defines BugReporter, a utility class for generating
11 // PathDiagnostics for analyses based on ProgramState.
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #ifndef LLVM_CLANG_STATICANALYZER_CORE_BUGREPORTER_BUGREPORTER_H
16 #define LLVM_CLANG_STATICANALYZER_CORE_BUGREPORTER_BUGREPORTER_H
17 
18 #include "clang/Basic/LLVM.h"
26 #include "llvm/ADT/ArrayRef.h"
27 #include "llvm/ADT/DenseSet.h"
28 #include "llvm/ADT/FoldingSet.h"
29 #include "llvm/ADT/ImmutableSet.h"
30 #include "llvm/ADT/None.h"
31 #include "llvm/ADT/SmallSet.h"
32 #include "llvm/ADT/SmallVector.h"
33 #include "llvm/ADT/StringMap.h"
34 #include "llvm/ADT/StringRef.h"
35 #include "llvm/ADT/ilist.h"
36 #include "llvm/ADT/ilist_node.h"
37 #include "llvm/ADT/iterator_range.h"
38 #include <cassert>
39 #include <memory>
40 #include <string>
41 #include <utility>
42 #include <vector>
43 
44 namespace clang {
45 
46 class AnalyzerOptions;
47 class ASTContext;
48 class Decl;
49 class DiagnosticsEngine;
50 class LocationContext;
51 class SourceManager;
52 class Stmt;
53 
54 namespace ento {
55 
56 class BugType;
57 class CheckerBase;
58 class ExplodedGraph;
59 class ExplodedNode;
60 class ExprEngine;
61 class MemRegion;
62 class SValBuilder;
63 
64 //===----------------------------------------------------------------------===//
65 // Interface for individual bug reports.
66 //===----------------------------------------------------------------------===//
67 
68 /// This class provides an interface through which checkers can create
69 /// individual bug reports.
70 class BugReport : public llvm::ilist_node<BugReport> {
71 public:
72  class NodeResolver {
73  virtual void anchor();
74 
75  public:
76  virtual ~NodeResolver() = default;
77 
78  virtual const ExplodedNode*
79  getOriginalNode(const ExplodedNode *N) = 0;
80  };
81 
82  using ranges_iterator = const SourceRange *;
84  using visitor_iterator = VisitorList::iterator;
87 
88 protected:
89  friend class BugReportEquivClass;
90  friend class BugReporter;
91 
93  const Decl *DeclWithIssue = nullptr;
94  std::string ShortDescription;
95  std::string Description;
99 
100  const ExplodedNode *ErrorNode = nullptr;
104 
107 
108  /// A (stack of) a set of symbols that are registered with this
109  /// report as being "interesting", and thus used to help decide which
110  /// diagnostics to include when constructing the final path diagnostic.
111  /// The stack is largely used by BugReporter when generating PathDiagnostics
112  /// for multiple PathDiagnosticConsumers.
114 
115  /// A (stack of) set of regions that are registered with this report as being
116  /// "interesting", and thus used to help decide which diagnostics
117  /// to include when constructing the final path diagnostic.
118  /// The stack is largely used by BugReporter when generating PathDiagnostics
119  /// for multiple PathDiagnosticConsumers.
121 
122  /// A set of location contexts that correspoind to call sites which should be
123  /// considered "interesting".
124  llvm::SmallSet<const LocationContext *, 2> InterestingLocationContexts;
125 
126  /// A set of custom visitors which generate "event" diagnostics at
127  /// interesting points in the path.
129 
130  /// Used for ensuring the visitors are only added once.
131  llvm::FoldingSet<BugReporterVisitor> CallbacksSet;
132 
133  /// Used for clients to tell if the report's configuration has changed
134  /// since the last time they checked.
136 
137  /// When set, this flag disables all callstack pruning from a diagnostic
138  /// path. This is useful for some reports that want maximum fidelty
139  /// when reporting an issue.
140  bool DoNotPrunePath = false;
141 
142  /// Used to track unique reasons why a bug report might be invalid.
143  ///
144  /// \sa markInvalid
145  /// \sa removeInvalidation
146  using InvalidationRecord = std::pair<const void *, const void *>;
147 
148  /// If non-empty, this bug report is likely a false positive and should not be
149  /// shown to the user.
150  ///
151  /// \sa markInvalid
152  /// \sa removeInvalidation
153  llvm::SmallSet<InvalidationRecord, 4> Invalidations;
154 
155 private:
156  // Used internally by BugReporter.
157  Symbols &getInterestingSymbols();
158  Regions &getInterestingRegions();
159 
160  void lazyInitializeInterestingSets();
161  void pushInterestingSymbolsAndRegions();
162  void popInterestingSymbolsAndRegions();
163 
164 public:
165  BugReport(BugType& bt, StringRef desc, const ExplodedNode *errornode)
166  : BT(bt), Description(desc), ErrorNode(errornode) {}
167 
168  BugReport(BugType& bt, StringRef shortDesc, StringRef desc,
169  const ExplodedNode *errornode)
170  : BT(bt), ShortDescription(shortDesc), Description(desc),
171  ErrorNode(errornode) {}
172 
173  BugReport(BugType &bt, StringRef desc, PathDiagnosticLocation l)
174  : BT(bt), Description(desc), Location(l) {}
175 
176  /// Create a BugReport with a custom uniqueing location.
177  ///
178  /// The reports that have the same report location, description, bug type, and
179  /// ranges are uniqued - only one of the equivalent reports will be presented
180  /// to the user. This method allows to rest the location which should be used
181  /// for uniquing reports. For example, memory leaks checker, could set this to
182  /// the allocation site, rather then the location where the bug is reported.
183  BugReport(BugType& bt, StringRef desc, const ExplodedNode *errornode,
184  PathDiagnosticLocation LocationToUnique, const Decl *DeclToUnique)
185  : BT(bt), Description(desc), UniqueingLocation(LocationToUnique),
186  UniqueingDecl(DeclToUnique), ErrorNode(errornode) {}
187 
188  virtual ~BugReport();
189 
190  const BugType& getBugType() const { return BT; }
191  BugType& getBugType() { return BT; }
192 
193  /// True when the report has an execution path associated with it.
194  ///
195  /// A report is said to be path-sensitive if it was thrown against a
196  /// particular exploded node in the path-sensitive analysis graph.
197  /// Path-sensitive reports have their intermediate path diagnostics
198  /// auto-generated, perhaps with the help of checker-defined visitors,
199  /// and may contain extra notes.
200  /// Path-insensitive reports consist only of a single warning message
201  /// in a specific location, and perhaps extra notes.
202  /// Path-sensitive checkers are allowed to throw path-insensitive reports.
203  bool isPathSensitive() const { return ErrorNode != nullptr; }
204 
205  const ExplodedNode *getErrorNode() const { return ErrorNode; }
206 
207  StringRef getDescription() const { return Description; }
208 
209  StringRef getShortDescription(bool UseFallback = true) const {
210  if (ShortDescription.empty() && UseFallback)
211  return Description;
212  return ShortDescription;
213  }
214 
215  /// Indicates whether or not any path pruning should take place
216  /// when generating a PathDiagnostic from this BugReport.
217  bool shouldPrunePath() const { return !DoNotPrunePath; }
218 
219  /// Disable all path pruning when generating a PathDiagnostic.
220  void disablePathPruning() { DoNotPrunePath = true; }
221 
222  void markInteresting(SymbolRef sym);
223  void markInteresting(const MemRegion *R);
224  void markInteresting(SVal V);
225  void markInteresting(const LocationContext *LC);
226 
227  bool isInteresting(SymbolRef sym);
228  bool isInteresting(const MemRegion *R);
229  bool isInteresting(SVal V);
230  bool isInteresting(const LocationContext *LC);
231 
232  unsigned getConfigurationChangeToken() const {
234  }
235 
236  /// Returns whether or not this report should be considered valid.
237  ///
238  /// Invalid reports are those that have been classified as likely false
239  /// positives after the fact.
240  bool isValid() const {
241  return Invalidations.empty();
242  }
243 
244  /// Marks the current report as invalid, meaning that it is probably a false
245  /// positive and should not be reported to the user.
246  ///
247  /// The \p Tag and \p Data arguments are intended to be opaque identifiers for
248  /// this particular invalidation, where \p Tag represents the visitor
249  /// responsible for invalidation, and \p Data represents the reason this
250  /// visitor decided to invalidate the bug report.
251  ///
252  /// \sa removeInvalidation
253  void markInvalid(const void *Tag, const void *Data) {
254  Invalidations.insert(std::make_pair(Tag, Data));
255  }
256 
257  /// Return the canonical declaration, be it a method or class, where
258  /// this issue semantically occurred.
259  const Decl *getDeclWithIssue() const;
260 
261  /// Specifically set the Decl where an issue occurred. This isn't necessary
262  /// for BugReports that cover a path as it will be automatically inferred.
263  void setDeclWithIssue(const Decl *declWithIssue) {
264  DeclWithIssue = declWithIssue;
265  }
266 
267  /// Add new item to the list of additional notes that need to be attached to
268  /// this path-insensitive report. If you want to add extra notes to a
269  /// path-sensitive report, you need to use a BugReporterVisitor because it
270  /// allows you to specify where exactly in the auto-generated path diagnostic
271  /// the extra note should appear.
272  void addNote(StringRef Msg, const PathDiagnosticLocation &Pos,
273  ArrayRef<SourceRange> Ranges) {
274  auto P = std::make_shared<PathDiagnosticNotePiece>(Pos, Msg);
275 
276  for (const auto &R : Ranges)
277  P->addRange(R);
278 
279  Notes.push_back(std::move(P));
280  }
281 
282  // FIXME: Instead of making an override, we could have default-initialized
283  // Ranges with {}, however it crashes the MSVC 2013 compiler.
284  void addNote(StringRef Msg, const PathDiagnosticLocation &Pos) {
285  std::vector<SourceRange> Ranges;
286  addNote(Msg, Pos, Ranges);
287  }
288 
289  virtual const NoteList &getNotes() {
290  return Notes;
291  }
292 
293  /// This allows for addition of meta data to the diagnostic.
294  ///
295  /// Currently, only the HTMLDiagnosticClient knows how to display it.
296  void addExtraText(StringRef S) {
297  ExtraText.push_back(S);
298  }
299 
300  virtual const ExtraTextList &getExtraText() {
301  return ExtraText;
302  }
303 
304  /// Return the "definitive" location of the reported bug.
305  ///
306  /// While a bug can span an entire path, usually there is a specific
307  /// location that can be used to identify where the key issue occurred.
308  /// This location is used by clients rendering diagnostics.
309  virtual PathDiagnosticLocation getLocation(const SourceManager &SM) const;
310 
311  /// Get the location on which the report should be uniqued.
313  return UniqueingLocation;
314  }
315 
316  /// Get the declaration containing the uniqueing location.
317  const Decl *getUniqueingDecl() const {
318  return UniqueingDecl;
319  }
320 
321  const Stmt *getStmt() const;
322 
323  /// Add a range to a bug report.
324  ///
325  /// Ranges are used to highlight regions of interest in the source code.
326  /// They should be at the same source code line as the BugReport location.
327  /// By default, the source range of the statement corresponding to the error
328  /// node will be used; add a single invalid range to specify absence of
329  /// ranges.
331  assert((R.isValid() || Ranges.empty()) && "Invalid range can only be used "
332  "to specify that the report does not have a range.");
333  Ranges.push_back(R);
334  }
335 
336  /// Get the SourceRanges associated with the report.
337  virtual llvm::iterator_range<ranges_iterator> getRanges();
338 
339  /// Add custom or predefined bug report visitors to this report.
340  ///
341  /// The visitors should be used when the default trace is not sufficient.
342  /// For example, they allow constructing a more elaborate trace.
343  /// \sa registerConditionVisitor(), registerTrackNullOrUndefValue(),
344  /// registerFindLastStore(), registerNilReceiverVisitor(), and
345  /// registerVarDeclsLastStore().
346  void addVisitor(std::unique_ptr<BugReporterVisitor> visitor);
347 
348  /// Iterators through the custom diagnostic visitors.
349  visitor_iterator visitor_begin() { return Callbacks.begin(); }
350  visitor_iterator visitor_end() { return Callbacks.end(); }
351 
352  /// Profile to identify equivalent bug reports for error report coalescing.
353  /// Reports are uniqued to ensure that we do not emit multiple diagnostics
354  /// for each bug.
355  virtual void Profile(llvm::FoldingSetNodeID& hash) const;
356 };
357 
358 //===----------------------------------------------------------------------===//
359 // BugTypes (collections of related reports).
360 //===----------------------------------------------------------------------===//
361 
362 class BugReportEquivClass : public llvm::FoldingSetNode {
363  friend class BugReporter;
364 
365  /// List of *owned* BugReport objects.
366  llvm::ilist<BugReport> Reports;
367 
368  void AddReport(std::unique_ptr<BugReport> R) {
369  Reports.push_back(R.release());
370  }
371 
372 public:
373  BugReportEquivClass(std::unique_ptr<BugReport> R) { AddReport(std::move(R)); }
375 
376  void Profile(llvm::FoldingSetNodeID& ID) const {
377  assert(!Reports.empty());
378  Reports.front().Profile(ID);
379  }
380 
381  using iterator = llvm::ilist<BugReport>::iterator;
382  using const_iterator = llvm::ilist<BugReport>::const_iterator;
383 
384  iterator begin() { return Reports.begin(); }
385  iterator end() { return Reports.end(); }
386 
387  const_iterator begin() const { return Reports.begin(); }
388  const_iterator end() const { return Reports.end(); }
389 };
390 
391 //===----------------------------------------------------------------------===//
392 // BugReporter and friends.
393 //===----------------------------------------------------------------------===//
394 
396 public:
397  virtual ~BugReporterData();
398 
399  virtual DiagnosticsEngine& getDiagnostic() = 0;
400  virtual ArrayRef<PathDiagnosticConsumer*> getPathDiagnosticConsumers() = 0;
401  virtual ASTContext &getASTContext() = 0;
402  virtual SourceManager &getSourceManager() = 0;
403  virtual AnalyzerOptions &getAnalyzerOptions() = 0;
404 };
405 
406 /// BugReporter is a utility class for generating PathDiagnostics for analysis.
407 /// It collects the BugReports and BugTypes and knows how to generate
408 /// and flush the corresponding diagnostics.
409 class BugReporter {
410 public:
411  enum Kind { BaseBRKind, GRBugReporterKind };
412 
413 private:
414  using BugTypesTy = llvm::ImmutableSet<BugType *>;
415 
416  BugTypesTy::Factory F;
417  BugTypesTy BugTypes;
418 
419  const Kind kind;
420  BugReporterData& D;
421 
422  /// Generate and flush the diagnostics for the given bug report.
423  void FlushReport(BugReportEquivClass& EQ);
424 
425  /// Generate and flush the diagnostics for the given bug report
426  /// and PathDiagnosticConsumer.
427  void FlushReport(BugReport *exampleReport,
429  ArrayRef<BugReport*> BugReports);
430 
431  /// The set of bug reports tracked by the BugReporter.
432  llvm::FoldingSet<BugReportEquivClass> EQClasses;
433 
434  /// A vector of BugReports for tracking the allocated pointers and cleanup.
435  std::vector<BugReportEquivClass *> EQClassesVector;
436 
437 protected:
439  : BugTypes(F.getEmptySet()), kind(k), D(d) {}
440 
441 public:
443  : BugTypes(F.getEmptySet()), kind(BaseBRKind), D(d) {}
444  virtual ~BugReporter();
445 
446  /// Generate and flush diagnostics for all bug reports.
447  void FlushReports();
448 
449  Kind getKind() const { return kind; }
450 
452  return D.getDiagnostic();
453  }
454 
456  return D.getPathDiagnosticConsumers();
457  }
458 
459  /// Iterator over the set of BugTypes tracked by the BugReporter.
460  using iterator = BugTypesTy::iterator;
461  iterator begin() { return BugTypes.begin(); }
462  iterator end() { return BugTypes.end(); }
463 
464  /// Iterator over the set of BugReports tracked by the BugReporter.
465  using EQClasses_iterator = llvm::FoldingSet<BugReportEquivClass>::iterator;
466  EQClasses_iterator EQClasses_begin() { return EQClasses.begin(); }
467  EQClasses_iterator EQClasses_end() { return EQClasses.end(); }
468 
470 
472 
474 
475  virtual bool generatePathDiagnostic(PathDiagnostic& pathDiagnostic,
477  ArrayRef<BugReport *> &bugReports) {
478  return true;
479  }
480 
481  void Register(BugType *BT);
482 
483  /// Add the given report to the set of reports tracked by BugReporter.
484  ///
485  /// The reports are usually generated by the checkers. Further, they are
486  /// folded based on the profile value, which is done to coalesce similar
487  /// reports.
488  void emitReport(std::unique_ptr<BugReport> R);
489 
490  void EmitBasicReport(const Decl *DeclWithIssue, const CheckerBase *Checker,
491  StringRef BugName, StringRef BugCategory,
492  StringRef BugStr, PathDiagnosticLocation Loc,
494 
495  void EmitBasicReport(const Decl *DeclWithIssue, CheckName CheckName,
496  StringRef BugName, StringRef BugCategory,
497  StringRef BugStr, PathDiagnosticLocation Loc,
499 
500 private:
501  llvm::StringMap<BugType *> StrBugTypes;
502 
503  /// Returns a BugType that is associated with the given name and
504  /// category.
505  BugType *getBugTypeForName(CheckName CheckName, StringRef name,
506  StringRef category);
507 };
508 
509 // FIXME: Get rid of GRBugReporter. It's the wrong abstraction.
510 class GRBugReporter : public BugReporter {
511  ExprEngine& Eng;
512 
513 public:
515  : BugReporter(d, GRBugReporterKind), Eng(eng) {}
516 
517  ~GRBugReporter() override;
518 
519  /// getEngine - Return the analysis engine used to analyze a given
520  /// function or method.
521  ExprEngine &getEngine() { return Eng; }
522 
523  /// getGraph - Get the exploded graph created by the analysis engine
524  /// for the analyzed method or function.
525  ExplodedGraph &getGraph();
526 
527  /// getStateManager - Return the state manager used by the analysis
528  /// engine.
529  ProgramStateManager &getStateManager();
530 
531  /// Generates a path corresponding to one of the given bug reports.
532  ///
533  /// Which report is used for path generation is not specified. The
534  /// bug reporter will try to pick the shortest path, but this is not
535  /// guaranteed.
536  ///
537  /// \return True if the report was valid and a path was generated,
538  /// false if the reports should be considered invalid.
539  bool generatePathDiagnostic(PathDiagnostic &PD, PathDiagnosticConsumer &PC,
540  ArrayRef<BugReport*> &bugReports) override;
541 
542  /// classof - Used by isa<>, cast<>, and dyn_cast<>.
543  static bool classof(const BugReporter* R) {
544  return R->getKind() == GRBugReporterKind;
545  }
546 };
547 
549  GRBugReporter &BR;
550 
551  virtual void anchor();
552 
553 public:
555 
556  virtual ~BugReporterContext() = default;
557 
558  GRBugReporter& getBugReporter() { return BR; }
559 
560  ExplodedGraph &getGraph() { return BR.getGraph(); }
561 
563  return BR.getStateManager();
564  }
565 
567  return getStateManager().getSValBuilder();
568  }
569 
571  return BR.getContext();
572  }
573 
575  return BR.getSourceManager();
576  }
577 
578  virtual BugReport::NodeResolver& getNodeResolver() = 0;
579 };
580 
581 } // namespace ento
582 
583 } // namespace clang
584 
585 #endif // LLVM_CLANG_STATICANALYZER_CORE_BUGREPORTER_BUGREPORTER_H
BugReporter(BugReporterData &d)
Definition: BugReporter.h:442
bool shouldPrunePath() const
Indicates whether or not any path pruning should take place when generating a PathDiagnostic from thi...
Definition: BugReporter.h:217
MemRegion - The root abstract class for all memory regions.
Definition: MemRegion.h:94
PathDiagnosticLocation getUniqueingLocation() const
Get the location on which the report should be uniqued.
Definition: BugReporter.h:312
bool isInteresting(SymbolRef sym)
Stmt - This represents one statement.
Definition: Stmt.h:66
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:86
StringRef getDescription() const
Definition: BugReporter.h:207
StringRef P
BugReport(BugType &bt, StringRef shortDesc, StringRef desc, const ExplodedNode *errornode)
Definition: BugReporter.h:168
ArrayRef< PathDiagnosticConsumer * > getPathDiagnosticConsumers()
Definition: BugReporter.h:455
The l-value was an access to a declared entity or something equivalently strong, like the address of ...
virtual PathDiagnosticLocation getLocation(const SourceManager &SM) const
Return the "definitive" location of the reported bug.
void addNote(StringRef Msg, const PathDiagnosticLocation &Pos)
Definition: BugReporter.h:284
void disablePathPruning()
Disable all path pruning when generating a PathDiagnostic.
Definition: BugReporter.h:220
SmallVector< SourceRange, 4 > Ranges
Definition: BugReporter.h:101
virtual bool generatePathDiagnostic(PathDiagnostic &pathDiagnostic, PathDiagnosticConsumer &PC, ArrayRef< BugReport *> &bugReports)
Definition: BugReporter.h:475
virtual AnalyzerOptions & getAnalyzerOptions()=0
Symbolic value.
Definition: SymExpr.h:30
PathDiagnostic - PathDiagnostic objects represent a single path-sensitive diagnostic.
void addRange(SourceRange R)
Add a range to a bug report.
Definition: BugReporter.h:330
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:150
BugReport(BugType &bt, StringRef desc, const ExplodedNode *errornode, PathDiagnosticLocation LocationToUnique, const Decl *DeclToUnique)
Create a BugReport with a custom uniqueing location.
Definition: BugReporter.h:183
bool isValid() const
Returns whether or not this report should be considered valid.
Definition: BugReporter.h:240
std::string ShortDescription
Definition: BugReporter.h:94
virtual DiagnosticsEngine & getDiagnostic()=0
llvm::SmallSet< InvalidationRecord, 4 > Invalidations
If non-empty, this bug report is likely a false positive and should not be shown to the user...
Definition: BugReporter.h:153
SmallVector< Regions *, 2 > interestingRegions
A (stack of) set of regions that are registered with this report as being "interesting", and thus used to help decide which diagnostics to include when constructing the final path diagnostic.
Definition: BugReporter.h:120
virtual llvm::iterator_range< ranges_iterator > getRanges()
Get the SourceRanges associated with the report.
llvm::FoldingSet< BugReporterVisitor > CallbacksSet
Used for ensuring the visitors are only added once.
Definition: BugReporter.h:131
const Stmt * getStmt() const
llvm::SmallSet< const LocationContext *, 2 > InterestingLocationContexts
A set of location contexts that correspoind to call sites which should be considered "interesting"...
Definition: BugReporter.h:124
const BugType & getBugType() const
Definition: BugReporter.h:190
BugReporter(BugReporterData &d, Kind k)
Definition: BugReporter.h:438
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
ASTContext & getContext()
Definition: BugReporter.h:469
Concrete class used by the front-end to report problems and issues.
Definition: Diagnostic.h:149
void Profile(llvm::FoldingSetNodeID &ID) const
Definition: BugReporter.h:376
GRBugReporter(BugReporterData &d, ExprEngine &eng)
Definition: BugReporter.h:514
const Decl * getDeclWithIssue() const
Return the canonical declaration, be it a method or class, where this issue semantically occurred...
BugReporterContext(GRBugReporter &br)
Definition: BugReporter.h:554
void addVisitor(std::unique_ptr< BugReporterVisitor > visitor)
Add custom or predefined bug report visitors to this report.
virtual const NoteList & getNotes()
Definition: BugReporter.h:289
const_iterator begin() const
Definition: BugReporter.h:387
const Decl * UniqueingDecl
Definition: BugReporter.h:98
unsigned getConfigurationChangeToken() const
Definition: BugReporter.h:232
VisitorList::iterator visitor_iterator
Definition: BugReporter.h:84
BugReportEquivClass(std::unique_ptr< BugReport > R)
Definition: BugReporter.h:373
bool DoNotPrunePath
When set, this flag disables all callstack pruning from a diagnostic path.
Definition: BugReporter.h:140
virtual const ExtraTextList & getExtraText()
Definition: BugReporter.h:300
BugTypesTy::iterator iterator
Iterator over the set of BugTypes tracked by the BugReporter.
Definition: BugReporter.h:460
visitor_iterator visitor_end()
Definition: BugReporter.h:350
visitor_iterator visitor_begin()
Iterators through the custom diagnostic visitors.
Definition: BugReporter.h:349
BugReport(BugType &bt, StringRef desc, PathDiagnosticLocation l)
Definition: BugReporter.h:173
virtual SourceManager & getSourceManager()=0
const Decl * getUniqueingDecl() const
Get the declaration containing the uniqueing location.
Definition: BugReporter.h:317
unsigned ConfigurationChangeToken
Used for clients to tell if the report&#39;s configuration has changed since the last time they checked...
Definition: BugReporter.h:135
void addNote(StringRef Msg, const PathDiagnosticLocation &Pos, ArrayRef< SourceRange > Ranges)
Add new item to the list of additional notes that need to be attached to this path-insensitive report...
Definition: BugReporter.h:272
void markInteresting(SymbolRef sym)
std::pair< const void *, const void * > InvalidationRecord
Used to track unique reasons why a bug report might be invalid.
Definition: BugReporter.h:146
const SourceManager & SM
Definition: Format.cpp:1468
AnalyzerOptions & getAnalyzerOptions()
Definition: BugReporter.h:473
virtual ArrayRef< PathDiagnosticConsumer * > getPathDiagnosticConsumers()=0
BugReporter is a utility class for generating PathDiagnostics for analysis.
Definition: BugReporter.h:409
PathDiagnosticLocation UniqueingLocation
Definition: BugReporter.h:97
static bool classof(const BugReporter *R)
classof - Used by isa<>, cast<>, and dyn_cast<>.
Definition: BugReporter.h:543
EQClasses_iterator EQClasses_begin()
Definition: BugReporter.h:466
const ExplodedNode * ErrorNode
Definition: BugReporter.h:100
ExplodedGraph & getGraph()
getGraph - Get the exploded graph created by the analysis engine for the analyzed method or function...
std::string Description
Definition: BugReporter.h:95
SVal - This represents a symbolic expression, which can be either an L-value or an R-value...
Definition: SVals.h:76
PathDiagnosticLocation Location
Definition: BugReporter.h:96
const Decl * DeclWithIssue
Definition: BugReporter.h:93
VisitorList Callbacks
A set of custom visitors which generate "event" diagnostics at interesting points in the path...
Definition: BugReporter.h:128
SmallVector< Symbols *, 2 > interestingSymbols
A (stack of) a set of symbols that are registered with this report as being "interesting", and thus used to help decide which diagnostics to include when constructing the final path diagnostic.
Definition: BugReporter.h:113
Dataflow Directional Tag Classes.
ExtraTextList ExtraText
Definition: BugReporter.h:102
BugType & getBugType()
Definition: BugReporter.h:191
GRBugReporter & getBugReporter()
Definition: BugReporter.h:558
DiagnosticsEngine & getDiagnostic()
Definition: BugReporter.h:451
const_iterator end() const
Definition: BugReporter.h:388
ProgramStateManager & getStateManager()
Definition: BugReporter.h:562
const ExplodedNode * getErrorNode() const
Definition: BugReporter.h:205
virtual void Profile(llvm::FoldingSetNodeID &hash) const
Profile to identify equivalent bug reports for error report coalescing.
EQClasses_iterator EQClasses_end()
Definition: BugReporter.h:467
StringRef getShortDescription(bool UseFallback=true) const
Definition: BugReporter.h:209
llvm::FoldingSet< BugReportEquivClass >::iterator EQClasses_iterator
Iterator over the set of BugReports tracked by the BugReporter.
Definition: BugReporter.h:465
llvm::ilist< BugReport >::iterator iterator
Definition: BugReporter.h:381
SourceManager & getSourceManager()
Definition: BugReporter.h:471
ProgramStateManager & getStateManager()
getStateManager - Return the state manager used by the analysis engine.
BugReport(BugType &bt, StringRef desc, const ExplodedNode *errornode)
Definition: BugReporter.h:165
Defines the clang::SourceLocation class and associated facilities.
bool isValid() const
void addExtraText(StringRef S)
This allows for addition of meta data to the diagnostic.
Definition: BugReporter.h:296
void markInvalid(const void *Tag, const void *Data)
Marks the current report as invalid, meaning that it is probably a false positive and should not be r...
Definition: BugReporter.h:253
unsigned kind
All of the diagnostics that can be emitted by the frontend.
Definition: DiagnosticIDs.h:61
virtual const ExplodedNode * getOriginalNode(const ExplodedNode *N)=0
A trivial tuple used to represent a source range.
This class provides an interface through which checkers can create individual bug reports...
Definition: BugReporter.h:70
llvm::ilist< BugReport >::const_iterator const_iterator
Definition: BugReporter.h:382
This class handles loading and caching of source files into memory.
virtual ASTContext & getASTContext()=0
SourceManager & getSourceManager()
Definition: BugReporter.h:574
void setDeclWithIssue(const Decl *declWithIssue)
Specifically set the Decl where an issue occurred.
Definition: BugReporter.h:263
bool isPathSensitive() const
True when the report has an execution path associated with it.
Definition: BugReporter.h:203
ExprEngine & getEngine()
getEngine - Return the analysis engine used to analyze a given function or method.
Definition: BugReporter.h:521