24using namespace iterator;
28class DebugIteratorModeling
31 const BugType DebugMsgBugType{
this,
"Checking analyzer assumptions",
"debug",
34 template <
typename Getter>
42 typedef void (DebugIteratorModeling::*FnCheck)(
const CallExpr *,
46 {{CDM::SimpleFunc, {
"clang_analyzer_iterator_position"}, 1},
47 &DebugIteratorModeling::analyzerIteratorPosition},
48 {{CDM::SimpleFunc, {
"clang_analyzer_iterator_container"}, 1},
49 &DebugIteratorModeling::analyzerIteratorContainer},
50 {{CDM::SimpleFunc, {
"clang_analyzer_iterator_validity"}, 1},
51 &DebugIteratorModeling::analyzerIteratorValidity},
62 const auto *CE = dyn_cast_or_null<CallExpr>(
Call.getOriginExpr());
66 const FnCheck *Handler = Callbacks.lookup(
Call);
70 (this->**Handler)(CE,
C);
74template <
typename Getter>
75void DebugIteratorModeling::analyzerIteratorDataField(
const CallExpr *CE,
80 reportDebugMsg(
"Missing iterator argument",
C);
84 auto State =
C.getState();
88 State = State->BindExpr(CE,
C.getLocationContext(), get(Pos));
90 State = State->BindExpr(CE,
C.getLocationContext(),
Default);
92 C.addTransition(State);
95void DebugIteratorModeling::analyzerIteratorPosition(
const CallExpr *CE,
97 auto &BVF =
C.getSValBuilder().getBasicValueFactory();
103void DebugIteratorModeling::analyzerIteratorContainer(
const CallExpr *CE,
105 auto &BVF =
C.getSValBuilder().getBasicValueFactory();
111void DebugIteratorModeling::analyzerIteratorValidity(
const CallExpr *CE,
113 auto &BVF =
C.getSValBuilder().getBasicValueFactory();
120ExplodedNode *DebugIteratorModeling::reportDebugMsg(llvm::StringRef Msg,
126 auto &BR =
C.getBugReporter();
128 std::make_unique<PathSensitiveBugReport>(DebugMsgBugType, Msg, N));
136bool ento::shouldRegisterDebugIteratorModeling(
const CheckerManager &mgr) {
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
unsigned getNumArgs() const
getNumArgs - Return the number of actual arguments to this call.
An immutable map from CallDescriptions to arbitrary data.
Represents an abstract call to a function or method along a particular path.
CHECKER * registerChecker(AT &&... Args)
Used to register checkers.
SVal - This represents a symbolic expression, which can be either an L-value or an R-value.
Value representing integer constant.
Represents symbolic expression that isn't a location.
const IteratorPosition * getIteratorPosition(ProgramStateRef State, SVal Val)
The JSON file list parser is used to communicate input to InstallAPI.