• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_ANALYSIS_BUGTYPE
15 #define LLVM_CLANG_ANALYSIS_BUGTYPE
16 
17 #include "llvm/ADT/FoldingSet.h"
18 #include <string>
19 
20 namespace clang {
21 
22 namespace ento {
23 
24 class BugReporter;
25 class ExplodedNode;
26 class ExprEngine;
27 
28 class BugType {
29 private:
30   const std::string Name;
31   const std::string Category;
32   bool SuppressonSink;
33 public:
BugType(StringRef name,StringRef cat)34   BugType(StringRef name, StringRef cat)
35     : Name(name), Category(cat), SuppressonSink(false) {}
36   virtual ~BugType();
37 
38   // FIXME: Should these be made strings as well?
getName()39   StringRef getName() const { return Name; }
getCategory()40   StringRef getCategory() const { return Category; }
41 
42   /// isSuppressOnSink - Returns true if bug reports associated with this bug
43   ///  type should be suppressed if the end node of the report is post-dominated
44   ///  by a sink node.
isSuppressOnSink()45   bool isSuppressOnSink() const { return SuppressonSink; }
setSuppressOnSink(bool x)46   void setSuppressOnSink(bool x) { SuppressonSink = x; }
47 
48   virtual void FlushReports(BugReporter& BR);
49 };
50 
51 class BuiltinBug : public BugType {
52   virtual void anchor();
53   const std::string desc;
54 public:
BuiltinBug(const char * name,const char * description)55   BuiltinBug(const char *name, const char *description)
56     : BugType(name, "Logic error"), desc(description) {}
57 
BuiltinBug(const char * name)58   BuiltinBug(const char *name)
59     : BugType(name, "Logic error"), desc(name) {}
60 
getDescription()61   StringRef getDescription() const { return desc; }
62 };
63 
64 } // end GR namespace
65 
66 } // end clang namespace
67 #endif
68