14 #include "llvm/ADT/StringSwitch.h"
16 using namespace clang;
20 class ExprInspectionChecker :
public Checker< eval::Call > {
21 mutable std::unique_ptr<BugType> BT;
28 typedef void (ExprInspectionChecker::*FnCheck)(
const CallExpr *,
36 bool ExprInspectionChecker::evalCall(
const CallExpr *CE,
40 FnCheck Handler = llvm::StringSwitch<FnCheck>(C.
getCalleeName(CE))
41 .Case(
"clang_analyzer_eval", &ExprInspectionChecker::analyzerEval)
42 .Case(
"clang_analyzer_checkInlined",
43 &ExprInspectionChecker::analyzerCheckInlined)
44 .Case(
"clang_analyzer_crash", &ExprInspectionChecker::analyzerCrash)
45 .Case(
"clang_analyzer_warnIfReached", &ExprInspectionChecker::analyzerWarnIfReached)
51 (this->*Handler)(CE, C);
58 return "Missing assertion argument";
65 SVal AssertionVal = State->getSVal(Assertion, LC);
71 std::tie(StTrue, StFalse) =
83 llvm_unreachable(
"Invalid constraint; neither true or false.");
87 void ExprInspectionChecker::analyzerEval(
const CallExpr *CE,
98 BT.reset(
new BugType(
this,
"Checking analyzer assumptions",
"debug"));
104 void ExprInspectionChecker::analyzerWarnIfReached(
const CallExpr *CE,
109 BT.reset(
new BugType(
this,
"Checking analyzer assumptions",
"debug"));
111 C.
emitReport(llvm::make_unique<BugReport>(*BT,
"REACHABLE", N));
114 void ExprInspectionChecker::analyzerCheckInlined(
const CallExpr *CE,
128 BT.reset(
new BugType(
this,
"Checking analyzer assumptions",
"debug"));
134 void ExprInspectionChecker::analyzerCrash(
const CallExpr *CE,
StringRef getCalleeName(const FunctionDecl *FunDecl) const
Get the name of the called function (path-sensitive).
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
ExplodedNode * getPredecessor()
Returns the previous node in the exploded graph, which includes the state of the program before the c...
const LocationContext * getLocationContext() const
const ProgramStateRef & getState() const
void emitReport(std::unique_ptr< BugReport > R)
Emit the diagnostics report.
CHECKER * registerChecker()
Used to register checkers.
const StackFrameContext * getCurrentStackFrame() const
const LocationContext * getParent() const
static const char * getArgumentValueString(const CallExpr *CE, CheckerContext &C)
unsigned getNumArgs() const
T castAs() const
Convert to the specified SVal type, asserting that this SVal is of the desired type.