[analyzer] Refactoring: include/clang/Checker -> include/clang/GR
[clang.git] / include / clang / GR / BugReporter / BugType.h
blob8d105bfc61c1398852d732f2d38d8d73d12d86d1
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.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_CLANG_ANALYSIS_BUGTYPE
15 #define LLVM_CLANG_ANALYSIS_BUGTYPE
17 #include "clang/GR/BugReporter/BugReporter.h"
18 #include "llvm/ADT/FoldingSet.h"
19 #include <string>
21 namespace clang {
23 class ExplodedNode;
24 class GRExprEngine;
26 class BugType {
27 private:
28 const std::string Name;
29 const std::string Category;
30 llvm::FoldingSet<BugReportEquivClass> EQClasses;
31 friend class BugReporter;
32 bool SuppressonSink;
33 public:
34 BugType(llvm::StringRef name, llvm::StringRef cat)
35 : Name(name), Category(cat), SuppressonSink(false) {}
36 virtual ~BugType();
38 // FIXME: Should these be made strings as well?
39 llvm::StringRef getName() const { return Name; }
40 llvm::StringRef getCategory() const { return Category; }
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.
45 bool isSuppressOnSink() const { return SuppressonSink; }
46 void setSuppressOnSink(bool x) { SuppressonSink = x; }
48 virtual void FlushReports(BugReporter& BR);
50 typedef llvm::FoldingSet<BugReportEquivClass>::iterator iterator;
51 iterator begin() { return EQClasses.begin(); }
52 iterator end() { return EQClasses.end(); }
54 typedef llvm::FoldingSet<BugReportEquivClass>::const_iterator const_iterator;
55 const_iterator begin() const { return EQClasses.begin(); }
56 const_iterator end() const { return EQClasses.end(); }
59 class BuiltinBug : public BugType {
60 const std::string desc;
61 public:
62 BuiltinBug(const char *name, const char *description)
63 : BugType(name, "Logic error"), desc(description) {}
65 BuiltinBug(const char *name)
66 : BugType(name, "Logic error"), desc(name) {}
68 llvm::StringRef getDescription() const { return desc; }
71 } // end clang namespace
72 #endif