]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - include/clang/Analysis/PathSensitive/BugType.h
Update clang to r94309.
[FreeBSD/FreeBSD.git] / include / clang / Analysis / PathSensitive / 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/Analysis/PathSensitive/BugReporter.h"
18 #include <llvm/ADT/FoldingSet.h>
19 #include <string>
20
21 namespace clang {
22
23 class BugReportEquivClass;
24 class BugReporter;
25 class BuiltinBugReport;
26 class BugReporterContext;
27 class ExplodedNode;
28 class GRExprEngine;
29
30 class BugType {
31 private:
32   const std::string Name;
33   const std::string Category;
34   llvm::FoldingSet<BugReportEquivClass> EQClasses;
35   friend class BugReporter;
36   bool SuppressonSink;
37 public:
38   BugType(llvm::StringRef name, llvm::StringRef cat)
39     : Name(name), Category(cat), SuppressonSink(false) {}
40   virtual ~BugType();
41
42   // FIXME: Should these be made strings as well?
43   llvm::StringRef getName() const { return Name; }
44   llvm::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   typedef llvm::FoldingSet<BugReportEquivClass>::iterator iterator;
55   iterator begin() { return EQClasses.begin(); }
56   iterator end() { return EQClasses.end(); }
57
58   typedef llvm::FoldingSet<BugReportEquivClass>::const_iterator const_iterator;
59   const_iterator begin() const { return EQClasses.begin(); }
60   const_iterator end() const { return EQClasses.end(); }
61 };
62
63 class BuiltinBug : public BugType {
64   const std::string desc;
65 public:
66   BuiltinBug(const char *name, const char *description)
67     : BugType(name, "Logic error"), desc(description) {}
68   
69   BuiltinBug(const char *name)
70     : BugType(name, "Logic error"), desc(name) {}
71   
72   llvm::StringRef getDescription() const { return desc; }
73 };
74
75 } // end clang namespace
76 #endif