1218887Sdim//===--- BugType.h - Bug Information Desciption ----------------*- C++ -*-===// 2218887Sdim// 3218887Sdim// The LLVM Compiler Infrastructure 4218887Sdim// 5218887Sdim// This file is distributed under the University of Illinois Open Source 6218887Sdim// License. See LICENSE.TXT for details. 7218887Sdim// 8218887Sdim//===----------------------------------------------------------------------===// 9218887Sdim// 10218887Sdim// This file defines BugType, a class representing a bug type. 11218887Sdim// 12218887Sdim//===----------------------------------------------------------------------===// 13218887Sdim 14218887Sdim#ifndef LLVM_CLANG_ANALYSIS_BUGTYPE 15218887Sdim#define LLVM_CLANG_ANALYSIS_BUGTYPE 16218887Sdim 17263508Sdim#include "clang/StaticAnalyzer/Core/BugReporter/CommonBugCategories.h" 18249423Sdim#include "clang/Basic/LLVM.h" 19218887Sdim#include "llvm/ADT/FoldingSet.h" 20218887Sdim#include <string> 21218887Sdim 22218887Sdimnamespace clang { 23218887Sdim 24218887Sdimnamespace ento { 25218887Sdim 26226633Sdimclass BugReporter; 27218887Sdimclass ExplodedNode; 28218887Sdimclass ExprEngine; 29218887Sdim 30218887Sdimclass BugType { 31218887Sdimprivate: 32218887Sdim const std::string Name; 33218887Sdim const std::string Category; 34218887Sdim bool SuppressonSink; 35263508Sdim 36263508Sdim virtual void anchor(); 37218887Sdimpublic: 38226633Sdim BugType(StringRef name, StringRef cat) 39218887Sdim : Name(name), Category(cat), SuppressonSink(false) {} 40263508Sdim virtual ~BugType() {} 41218887Sdim 42218887Sdim // FIXME: Should these be made strings as well? 43226633Sdim StringRef getName() const { return Name; } 44226633Sdim StringRef getCategory() const { return Category; } 45218887Sdim 46218887Sdim /// isSuppressOnSink - Returns true if bug reports associated with this bug 47218887Sdim /// type should be suppressed if the end node of the report is post-dominated 48218887Sdim /// by a sink node. 49218887Sdim bool isSuppressOnSink() const { return SuppressonSink; } 50218887Sdim void setSuppressOnSink(bool x) { SuppressonSink = x; } 51218887Sdim 52218887Sdim virtual void FlushReports(BugReporter& BR); 53218887Sdim}; 54218887Sdim 55218887Sdimclass BuiltinBug : public BugType { 56263508Sdim const std::string desc; 57234353Sdim virtual void anchor(); 58218887Sdimpublic: 59218887Sdim BuiltinBug(const char *name, const char *description) 60263508Sdim : BugType(name, categories::LogicError), desc(description) {} 61218887Sdim 62218887Sdim BuiltinBug(const char *name) 63263508Sdim : BugType(name, categories::LogicError), desc(name) {} 64218887Sdim 65226633Sdim StringRef getDescription() const { return desc; } 66218887Sdim}; 67218887Sdim 68218887Sdim} // end GR namespace 69218887Sdim 70218887Sdim} // end clang namespace 71218887Sdim#endif 72