clang API Documentation
00001 //===--- BugType.h - Bug Information Desciption ----------------*- C++ -*-===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file is distributed under the University of Illinois Open Source 00006 // License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 // 00010 // This file defines BugType, a class representing a bug type. 00011 // 00012 //===----------------------------------------------------------------------===// 00013 00014 #ifndef LLVM_CLANG_STATICANALYZER_CORE_BUGREPORTER_BUGTYPE_H 00015 #define LLVM_CLANG_STATICANALYZER_CORE_BUGREPORTER_BUGTYPE_H 00016 00017 #include "clang/Basic/LLVM.h" 00018 #include "clang/StaticAnalyzer/Core/BugReporter/CommonBugCategories.h" 00019 #include "clang/StaticAnalyzer/Core/Checker.h" 00020 #include "llvm/ADT/FoldingSet.h" 00021 #include <string> 00022 00023 namespace clang { 00024 00025 namespace ento { 00026 00027 class BugReporter; 00028 class ExplodedNode; 00029 class ExprEngine; 00030 00031 class BugType { 00032 private: 00033 const CheckName Check; 00034 const std::string Name; 00035 const std::string Category; 00036 bool SuppressonSink; 00037 00038 virtual void anchor(); 00039 public: 00040 BugType(class CheckName check, StringRef name, StringRef cat) 00041 : Check(check), Name(name), Category(cat), SuppressonSink(false) {} 00042 BugType(const CheckerBase *checker, StringRef name, StringRef cat) 00043 : Check(checker->getCheckName()), Name(name), Category(cat), 00044 SuppressonSink(false) {} 00045 virtual ~BugType() {} 00046 00047 // FIXME: Should these be made strings as well? 00048 StringRef getName() const { return Name; } 00049 StringRef getCategory() const { return Category; } 00050 StringRef getCheckName() const { return Check.getName(); } 00051 00052 /// isSuppressOnSink - Returns true if bug reports associated with this bug 00053 /// type should be suppressed if the end node of the report is post-dominated 00054 /// by a sink node. 00055 bool isSuppressOnSink() const { return SuppressonSink; } 00056 void setSuppressOnSink(bool x) { SuppressonSink = x; } 00057 00058 virtual void FlushReports(BugReporter& BR); 00059 }; 00060 00061 class BuiltinBug : public BugType { 00062 const std::string desc; 00063 void anchor() override; 00064 public: 00065 BuiltinBug(class CheckName check, const char *name, const char *description) 00066 : BugType(check, name, categories::LogicError), desc(description) {} 00067 00068 BuiltinBug(const CheckerBase *checker, const char *name, 00069 const char *description) 00070 : BugType(checker, name, categories::LogicError), desc(description) {} 00071 00072 BuiltinBug(const CheckerBase *checker, const char *name) 00073 : BugType(checker, name, categories::LogicError), desc(name) {} 00074 00075 StringRef getDescription() const { return desc; } 00076 }; 00077 00078 } // end GR namespace 00079 00080 } // end clang namespace 00081 #endif