clang  6.0.0svn
BugType.h
Go to the documentation of this file.
1 //===--- BugType.h - Bug Information Desciption ----------------*- 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 BugType, a class representing a bug type.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_CLANG_STATICANALYZER_CORE_BUGREPORTER_BUGTYPE_H
15 #define LLVM_CLANG_STATICANALYZER_CORE_BUGREPORTER_BUGTYPE_H
16 
17 #include "clang/Basic/LLVM.h"
20 #include <string>
21 
22 namespace clang {
23 
24 namespace ento {
25 
26 class BugReporter;
27 class ExplodedNode;
28 class ExprEngine;
29 
30 class BugType {
31 private:
32  const CheckName Check;
33  const std::string Name;
34  const std::string Category;
35  bool SuppressonSink;
36 
37  virtual void anchor();
38 public:
39  BugType(class CheckName check, StringRef name, StringRef cat)
40  : Check(check), Name(name), Category(cat), SuppressonSink(false) {}
41  BugType(const CheckerBase *checker, StringRef name, StringRef cat)
42  : Check(checker->getCheckName()), Name(name), Category(cat),
43  SuppressonSink(false) {}
44  virtual ~BugType() {}
45 
46  // FIXME: Should these be made strings as well?
47  StringRef getName() const { return Name; }
48  StringRef getCategory() const { return Category; }
49  StringRef getCheckName() const { return Check.getName(); }
50 
51  /// isSuppressOnSink - Returns true if bug reports associated with this bug
52  /// type should be suppressed if the end node of the report is post-dominated
53  /// by a sink node.
54  bool isSuppressOnSink() const { return SuppressonSink; }
55  void setSuppressOnSink(bool x) { SuppressonSink = x; }
56 
57  virtual void FlushReports(BugReporter& BR);
58 };
59 
60 class BuiltinBug : public BugType {
61  const std::string desc;
62  void anchor() override;
63 public:
64  BuiltinBug(class CheckName check, const char *name, const char *description)
65  : BugType(check, name, categories::LogicError), desc(description) {}
66 
67  BuiltinBug(const CheckerBase *checker, const char *name,
68  const char *description)
69  : BugType(checker, name, categories::LogicError), desc(description) {}
70 
71  BuiltinBug(const CheckerBase *checker, const char *name)
72  : BugType(checker, name, categories::LogicError), desc(name) {}
73 
74  StringRef getDescription() const { return desc; }
75 };
76 
77 } // end GR namespace
78 
79 } // end clang namespace
80 #endif
BuiltinBug(class CheckName check, const char *name, const char *description)
Definition: BugType.h:64
BugType(const CheckerBase *checker, StringRef name, StringRef cat)
Definition: BugType.h:41
virtual ~BugType()
Definition: BugType.h:44
StringRef getDescription() const
Definition: BugType.h:74
StringRef getName() const
Definition: BugType.h:47
StringRef getCategory() const
Definition: BugType.h:48
virtual void FlushReports(BugReporter &BR)
BuiltinBug(const CheckerBase *checker, const char *name)
Definition: BugType.h:71
BugType(class CheckName check, StringRef name, StringRef cat)
Definition: BugType.h:39
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
void setSuppressOnSink(bool x)
Definition: BugType.h:55
StringRef getName() const
BugReporter is a utility class for generating PathDiagnostics for analysis.
Definition: BugReporter.h:403
#define false
Definition: stdbool.h:33
Dataflow Directional Tag Classes.
StringRef getCheckName() const
Definition: BugType.h:49
bool isSuppressOnSink() const
isSuppressOnSink - Returns true if bug reports associated with this bug type should be suppressed if ...
Definition: BugType.h:54
BuiltinBug(const CheckerBase *checker, const char *name, const char *description)
Definition: BugType.h:67