]> CyberLeo.Net >> Repos - FreeBSD/releng/10.2.git/blob - contrib/llvm/tools/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugType.h
- Copy stable/10@285827 to releng/10.2 in preparation for 10.2-RC1
[FreeBSD/releng/10.2.git] / contrib / llvm / tools / clang / include / clang / StaticAnalyzer / Core / BugReporter / BugType.h
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 "clang/StaticAnalyzer/Core/BugReporter/CommonBugCategories.h"
18 #include "clang/Basic/LLVM.h"
19 #include "llvm/ADT/FoldingSet.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 std::string Name;
33   const std::string Category;
34   bool SuppressonSink;
35
36   virtual void anchor();
37 public:
38   BugType(StringRef name, StringRef cat)
39     : Name(name), Category(cat), SuppressonSink(false) {}
40   virtual ~BugType() {}
41
42   // FIXME: Should these be made strings as well?
43   StringRef getName() const { return Name; }
44   StringRef getCategory() const { return Category; }
45   
46   /// isSuppressOnSink - Returns true if bug reports associated with this bug
47   ///  type should be suppressed if the end node of the report is post-dominated
48   ///  by a sink node.
49   bool isSuppressOnSink() const { return SuppressonSink; }
50   void setSuppressOnSink(bool x) { SuppressonSink = x; }
51
52   virtual void FlushReports(BugReporter& BR);
53 };
54
55 class BuiltinBug : public BugType {
56   const std::string desc;
57   virtual void anchor();
58 public:
59   BuiltinBug(const char *name, const char *description)
60     : BugType(name, categories::LogicError), desc(description) {}
61   
62   BuiltinBug(const char *name)
63     : BugType(name, categories::LogicError), desc(name) {}
64   
65   StringRef getDescription() const { return desc; }
66 };
67
68 } // end GR namespace
69
70 } // end clang namespace
71 #endif