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  /// Reverses the effects of a previous invalidation.
258  ///
259  /// \sa markInvalid
260  void removeInvalidation(const void *Tag, const void *Data) {
261  Invalidations.erase(std::make_pair(Tag, Data));
262  }
263 
264  /// Return the canonical declaration, be it a method or class, where
265  /// this issue semantically occurred.
266  const Decl *getDeclWithIssue() const;
267 
268  /// Specifically set the Decl where an issue occurred. This isn't necessary
269  /// for BugReports that cover a path as it will be automatically inferred.
270  void setDeclWithIssue(const Decl *declWithIssue) {
271  DeclWithIssue = declWithIssue;
272  }
273 
274  /// Add new item to the list of additional notes that need to be attached to
275  /// this path-insensitive report. If you want to add extra notes to a
276  /// path-sensitive report, you need to use a BugReporterVisitor because it
277  /// allows you to specify where exactly in the auto-generated path diagnostic
278  /// the extra note should appear.
279  void addNote(StringRef Msg, const PathDiagnosticLocation &Pos,
280  ArrayRef<SourceRange> Ranges) {
281  auto P = std::make_shared<PathDiagnosticNotePiece>(Pos, Msg);
282 
283  for (const auto &R : Ranges)
284  P->addRange(R);
285 
286  Notes.push_back(std::move(P));
287  }
288 
289  // FIXME: Instead of making an override, we could have default-initialized
290  // Ranges with {}, however it crashes the MSVC 2013 compiler.
291  void addNote(StringRef Msg, const PathDiagnosticLocation &Pos) {
292  std::vector<SourceRange> Ranges;
293  addNote(Msg, Pos, Ranges);
294  }
295 
296  virtual const NoteList &getNotes() {
297  return Notes;
298  }
299 
300  /// This allows for addition of meta data to the diagnostic.
301  ///
302  /// Currently, only the HTMLDiagnosticClient knows how to display it.
303  void addExtraText(StringRef S) {
304  ExtraText.push_back(S);
305  }
306 
307  virtual const ExtraTextList &getExtraText() {
308  return ExtraText;
309  }
310 
311  /// Return the "definitive" location of the reported bug.
312  ///
313  /// While a bug can span an entire path, usually there is a specific
314  /// location that can be used to identify where the key issue occurred.
315  /// This location is used by clients rendering diagnostics.
316  virtual PathDiagnosticLocation getLocation(const SourceManager &SM) const;
317 
318  /// Get the location on which the report should be uniqued.
320  return UniqueingLocation;
321  }
322 
323  /// Get the declaration containing the uniqueing location.
324  const Decl *getUniqueingDecl() const {
325  return UniqueingDecl;
326  }
327 
328  const Stmt *getStmt() const;
329 
330  /// Add a range to a bug report.
331  ///
332  /// Ranges are used to highlight regions of interest in the source code.
333  /// They should be at the same source code line as the BugReport location.
334  /// By default, the source range of the statement corresponding to the error
335  /// node will be used; add a single invalid range to specify absence of
336  /// ranges.
338  assert((R.isValid() || Ranges.empty()) && "Invalid range can only be used "
339  "to specify that the report does not have a range.");
340  Ranges.push_back(R);
341  }
342 
343  /// Get the SourceRanges associated with the report.
344  virtual llvm::iterator_range<ranges_iterator> getRanges();
345 
346  /// Add custom or predefined bug report visitors to this report.
347  ///
348  /// The visitors should be used when the default trace is not sufficient.
349  /// For example, they allow constructing a more elaborate trace.
350  /// \sa registerConditionVisitor(), registerTrackNullOrUndefValue(),
351  /// registerFindLastStore(), registerNilReceiverVisitor(), and
352  /// registerVarDeclsLastStore().
353  void addVisitor(std::unique_ptr<BugReporterVisitor> visitor);
354 
355  /// Iterators through the custom diagnostic visitors.
356  visitor_iterator visitor_begin() { return Callbacks.begin(); }
357  visitor_iterator visitor_end() { return Callbacks.end(); }
358 
359  /// Profile to identify equivalent bug reports for error report coalescing.
360  /// Reports are uniqued to ensure that we do not emit multiple diagnostics
361  /// for each bug.
362  virtual void Profile(llvm::FoldingSetNodeID& hash) const;
363 };
364 
365 //===----------------------------------------------------------------------===//
366 // BugTypes (collections of related reports).
367 //===----------------------------------------------------------------------===//
368 
369 class BugReportEquivClass : public llvm::FoldingSetNode {
370  friend class BugReporter;
371 
372  /// List of *owned* BugReport objects.
373  llvm::ilist<BugReport> Reports;
374 
375  void AddReport(std::unique_ptr<BugReport> R) {
376  Reports.push_back(R.release());
377  }
378 
379 public:
380  BugReportEquivClass(std::unique_ptr<BugReport> R) { AddReport(std::move(R)); }
382 
383  void Profile(llvm::FoldingSetNodeID& ID) const {
384  assert(!Reports.empty());
385  Reports.front().Profile(ID);
386  }
387 
388  using iterator = llvm::ilist<BugReport>::iterator;
389  using const_iterator = llvm::ilist<BugReport>::const_iterator;
390 
391  iterator begin() { return Reports.begin(); }
392  iterator end() { return Reports.end(); }
393 
394  const_iterator begin() const { return Reports.begin(); }
395  const_iterator end() const { return Reports.end(); }
396 };
397 
398 //===----------------------------------------------------------------------===//
399 // BugReporter and friends.
400 //===----------------------------------------------------------------------===//
401 
403 public:
404  virtual ~BugReporterData();
405 
406  virtual DiagnosticsEngine& getDiagnostic() = 0;
407  virtual ArrayRef<PathDiagnosticConsumer*> getPathDiagnosticConsumers() = 0;
408  virtual ASTContext &getASTContext() = 0;
409  virtual SourceManager &getSourceManager() = 0;
410  virtual AnalyzerOptions &getAnalyzerOptions() = 0;
411 };
412 
413 /// BugReporter is a utility class for generating PathDiagnostics for analysis.
414 /// It collects the BugReports and BugTypes and knows how to generate
415 /// and flush the corresponding diagnostics.
416 class BugReporter {
417 public:
418  enum Kind { BaseBRKind, GRBugReporterKind };
419 
420 private:
421  using BugTypesTy = llvm::ImmutableSet<BugType *>;
422 
423  BugTypesTy::Factory F;
424  BugTypesTy BugTypes;
425 
426  const Kind kind;
427  BugReporterData& D;
428 
429  /// Generate and flush the diagnostics for the given bug report.
430  void FlushReport(BugReportEquivClass& EQ);
431 
432  /// Generate and flush the diagnostics for the given bug report
433  /// and PathDiagnosticConsumer.
434  void FlushReport(BugReport *exampleReport,
436  ArrayRef<BugReport*> BugReports);
437 
438  /// The set of bug reports tracked by the BugReporter.
439  llvm::FoldingSet<BugReportEquivClass> EQClasses;
440 
441  /// A vector of BugReports for tracking the allocated pointers and cleanup.
442  std::vector<BugReportEquivClass *> EQClassesVector;
443 
444 protected:
446  : BugTypes(F.getEmptySet()), kind(k), D(d) {}
447 
448 public:
450  : BugTypes(F.getEmptySet()), kind(BaseBRKind), D(d) {}
451  virtual ~BugReporter();
452 
453  /// Generate and flush diagnostics for all bug reports.
454  void FlushReports();
455 
456  Kind getKind() const { return kind; }
457 
459  return D.getDiagnostic();
460  }
461 
463  return D.getPathDiagnosticConsumers();
464  }
465 
466  /// Iterator over the set of BugTypes tracked by the BugReporter.
467  using iterator = BugTypesTy::iterator;
468  iterator begin() { return BugTypes.begin(); }
469  iterator end() { return BugTypes.end(); }
470 
471  /// Iterator over the set of BugReports tracked by the BugReporter.
472  using EQClasses_iterator = llvm::FoldingSet<BugReportEquivClass>::iterator;
473  EQClasses_iterator EQClasses_begin() { return EQClasses.begin(); }
474  EQClasses_iterator EQClasses_end() { return EQClasses.end(); }
475 
477 
479 
481 
482  virtual bool generatePathDiagnostic(PathDiagnostic& pathDiagnostic,
484  ArrayRef<BugReport *> &bugReports) {
485  return true;
486  }
487 
488  void Register(BugType *BT);
489 
490  /// Add the given report to the set of reports tracked by BugReporter.
491  ///
492  /// The reports are usually generated by the checkers. Further, they are
493  /// folded based on the profile value, which is done to coalesce similar
494  /// reports.
495  void emitReport(std::unique_ptr<BugReport> R);
496 
497  void EmitBasicReport(const Decl *DeclWithIssue, const CheckerBase *Checker,
498  StringRef BugName, StringRef BugCategory,
499  StringRef BugStr, PathDiagnosticLocation Loc,
501 
502  void EmitBasicReport(const Decl *DeclWithIssue, CheckName CheckName,
503  StringRef BugName, StringRef BugCategory,
504  StringRef BugStr, PathDiagnosticLocation Loc,
506 
507 private:
508  llvm::StringMap<BugType *> StrBugTypes;
509 
510  /// Returns a BugType that is associated with the given name and
511  /// category.
512  BugType *getBugTypeForName(CheckName CheckName, StringRef name,
513  StringRef category);
514 };
515 
516 // FIXME: Get rid of GRBugReporter. It's the wrong abstraction.
517 class GRBugReporter : public BugReporter {
518  ExprEngine& Eng;
519 
520 public:
522  : BugReporter(d, GRBugReporterKind), Eng(eng) {}
523 
524  ~GRBugReporter() override;
525 
526  /// getEngine - Return the analysis engine used to analyze a given
527  /// function or method.
528  ExprEngine &getEngine() { return Eng; }
529 
530  /// getGraph - Get the exploded graph created by the analysis engine
531  /// for the analyzed method or function.
532  ExplodedGraph &getGraph();
533 
534  /// getStateManager - Return the state manager used by the analysis
535  /// engine.
536  ProgramStateManager &getStateManager();
537 
538  /// Generates a path corresponding to one of the given bug reports.
539  ///
540  /// Which report is used for path generation is not specified. The
541  /// bug reporter will try to pick the shortest path, but this is not
542  /// guaranteed.
543  ///
544  /// \return True if the report was valid and a path was generated,
545  /// false if the reports should be considered invalid.
546  bool generatePathDiagnostic(PathDiagnostic &PD, PathDiagnosticConsumer &PC,
547  ArrayRef<BugReport*> &bugReports) override;
548 
549  /// classof - Used by isa<>, cast<>, and dyn_cast<>.
550  static bool classof(const BugReporter* R) {
551  return R->getKind() == GRBugReporterKind;
552  }
553 };
554 
556  GRBugReporter &BR;
557 
558  virtual void anchor();
559 
560 public:
562 
563  virtual ~BugReporterContext() = default;
564 
565  GRBugReporter& getBugReporter() { return BR; }
566 
567  ExplodedGraph &getGraph() { return BR.getGraph(); }
568 
570  return BR.getStateManager();
571  }
572 
574  return getStateManager().getSValBuilder();
575  }
576 
578  return BR.getContext();
579  }
580 
582  return BR.getSourceManager();
583  }
584 
585  virtual BugReport::NodeResolver& getNodeResolver() = 0;
586 };
587 
588 } // namespace ento
589 
590 } // namespace clang
591 
592 #endif // LLVM_CLANG_STATICANALYZER_CORE_BUGREPORTER_BUGREPORTER_H
BugReporter(BugReporterData &d)
Definition: BugReporter.h:449
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:319
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:462
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:291
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:482
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:337
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:445
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
ASTContext & getContext()
Definition: BugReporter.h:476
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:383
GRBugReporter(BugReporterData &d, ExprEngine &eng)
Definition: BugReporter.h:521
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:561
void addVisitor(std::unique_ptr< BugReporterVisitor > visitor)
Add custom or predefined bug report visitors to this report.
virtual const NoteList & getNotes()
Definition: BugReporter.h:296
const_iterator begin() const
Definition: BugReporter.h:394
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:380
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:307
BugTypesTy::iterator iterator
Iterator over the set of BugTypes tracked by the BugReporter.
Definition: BugReporter.h:467
visitor_iterator visitor_end()
Definition: BugReporter.h:357
visitor_iterator visitor_begin()
Iterators through the custom diagnostic visitors.
Definition: BugReporter.h:356
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:324
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:279
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:1442
AnalyzerOptions & getAnalyzerOptions()
Definition: BugReporter.h:480
virtual ArrayRef< PathDiagnosticConsumer * > getPathDiagnosticConsumers()=0
BugReporter is a utility class for generating PathDiagnostics for analysis.
Definition: BugReporter.h:416
PathDiagnosticLocation UniqueingLocation
Definition: BugReporter.h:97
static bool classof(const BugReporter *R)
classof - Used by isa<>, cast<>, and dyn_cast<>.
Definition: BugReporter.h:550
EQClasses_iterator EQClasses_begin()
Definition: BugReporter.h:473
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:565
DiagnosticsEngine & getDiagnostic()
Definition: BugReporter.h:458
const_iterator end() const
Definition: BugReporter.h:395
ProgramStateManager & getStateManager()
Definition: BugReporter.h:569
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:474
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:472
llvm::ilist< BugReport >::iterator iterator
Definition: BugReporter.h:388
SourceManager & getSourceManager()
Definition: BugReporter.h:478
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:303
void removeInvalidation(const void *Tag, const void *Data)
Reverses the effects of a previous invalidation.
Definition: BugReporter.h:260
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:389
This class handles loading and caching of source files into memory.
virtual ASTContext & getASTContext()=0
SourceManager & getSourceManager()
Definition: BugReporter.h:581
void setDeclWithIssue(const Decl *declWithIssue)
Specifically set the Decl where an issue occurred.
Definition: BugReporter.h:270
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:528