Home | History | Annotate | Download | only in BugReporter
      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/Basic/LLVM.h"
     18 #include "llvm/ADT/FoldingSet.h"
     19 #include <string>
     20 
     21 namespace clang {
     22 
     23 namespace ento {
     24 
     25 class BugReporter;
     26 class ExplodedNode;
     27 class ExprEngine;
     28 
     29 class BugType {
     30 private:
     31   const std::string Name;
     32   const std::string Category;
     33   bool SuppressonSink;
     34 public:
     35   BugType(StringRef name, StringRef cat)
     36     : Name(name), Category(cat), SuppressonSink(false) {}
     37   virtual ~BugType();
     38 
     39   // FIXME: Should these be made strings as well?
     40   StringRef getName() const { return Name; }
     41   StringRef getCategory() const { return Category; }
     42 
     43   /// isSuppressOnSink - Returns true if bug reports associated with this bug
     44   ///  type should be suppressed if the end node of the report is post-dominated
     45   ///  by a sink node.
     46   bool isSuppressOnSink() const { return SuppressonSink; }
     47   void setSuppressOnSink(bool x) { SuppressonSink = x; }
     48 
     49   virtual void FlushReports(BugReporter& BR);
     50 };
     51 
     52 class BuiltinBug : public BugType {
     53   virtual void anchor();
     54   const std::string desc;
     55 public:
     56   BuiltinBug(const char *name, const char *description)
     57     : BugType(name, "Logic error"), desc(description) {}
     58 
     59   BuiltinBug(const char *name)
     60     : BugType(name, "Logic error"), desc(name) {}
     61 
     62   StringRef getDescription() const { return desc; }
     63 };
     64 
     65 } // end GR namespace
     66 
     67 } // end clang namespace
     68 #endif
     69