diff options
Diffstat (limited to 'lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp')
| -rw-r--r-- | lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp | 20 | 
1 files changed, 20 insertions, 0 deletions
| diff --git a/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp b/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp index 810473f1a6e03..3ed2435b92edd 100644 --- a/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp @@ -22,6 +22,8 @@ class ExprInspectionChecker : public Checker< eval::Call > {    void analyzerEval(const CallExpr *CE, CheckerContext &C) const;    void analyzerCheckInlined(const CallExpr *CE, CheckerContext &C) const; +  void analyzerWarnIfReached(const CallExpr *CE, CheckerContext &C) const; +  void analyzerCrash(const CallExpr *CE, CheckerContext &C) const;    typedef void (ExprInspectionChecker::*FnCheck)(const CallExpr *,                                                   CheckerContext &C) const; @@ -39,6 +41,8 @@ bool ExprInspectionChecker::evalCall(const CallExpr *CE,      .Case("clang_analyzer_eval", &ExprInspectionChecker::analyzerEval)      .Case("clang_analyzer_checkInlined",            &ExprInspectionChecker::analyzerCheckInlined) +    .Case("clang_analyzer_crash", &ExprInspectionChecker::analyzerCrash) +    .Case("clang_analyzer_warnIfReached", &ExprInspectionChecker::analyzerWarnIfReached)      .Default(0);    if (!Handler) @@ -97,6 +101,17 @@ void ExprInspectionChecker::analyzerEval(const CallExpr *CE,    C.emitReport(R);  } +void ExprInspectionChecker::analyzerWarnIfReached(const CallExpr *CE, +                                                  CheckerContext &C) const { +  ExplodedNode *N = C.getPredecessor(); + +  if (!BT) +    BT.reset(new BugType("Checking analyzer assumptions", "debug")); + +  BugReport *R = new BugReport(*BT, "REACHABLE", N); +  C.emitReport(R); +} +  void ExprInspectionChecker::analyzerCheckInlined(const CallExpr *CE,                                                   CheckerContext &C) const {    ExplodedNode *N = C.getPredecessor(); @@ -117,6 +132,11 @@ void ExprInspectionChecker::analyzerCheckInlined(const CallExpr *CE,    C.emitReport(R);  } +void ExprInspectionChecker::analyzerCrash(const CallExpr *CE, +                                          CheckerContext &C) const { +  LLVM_BUILTIN_TRAP; +} +  void ento::registerExprInspectionChecker(CheckerManager &Mgr) {    Mgr.registerChecker<ExprInspectionChecker>();  } | 
