24using namespace iterator;
28class DebugContainerModeling
31 const BugType DebugMsgBugType{
this,
"Checking analyzer assumptions",
"debug",
34 template <
typename Getter>
41 typedef void (DebugContainerModeling::*FnCheck)(
const CallExpr *,
45 {{CDM::SimpleFunc, {
"clang_analyzer_container_begin"}, 1},
46 &DebugContainerModeling::analyzerContainerBegin},
47 {{CDM::SimpleFunc, {
"clang_analyzer_container_end"}, 1},
48 &DebugContainerModeling::analyzerContainerEnd},
59 const auto *CE = dyn_cast_or_null<CallExpr>(
Call.getOriginExpr());
63 const FnCheck *Handler = Callbacks.lookup(
Call);
67 (this->**Handler)(CE,
C);
71template <
typename Getter>
72void DebugContainerModeling::analyzerContainerDataField(
const CallExpr *CE,
76 reportDebugMsg(
"Missing container argument",
C);
80 auto State =
C.getState();
87 State = State->BindExpr(CE,
C.getLocationContext(),
97 BR.markInteresting(Cont);
101 C.addTransition(State, InterestingTag);
107 auto &BVF =
C.getSValBuilder().getBasicValueFactory();
108 State = State->BindExpr(CE,
C.getLocationContext(),
112void DebugContainerModeling::analyzerContainerBegin(
const CallExpr *CE,
115 return D->getBegin();
119void DebugContainerModeling::analyzerContainerEnd(
const CallExpr *CE,
126ExplodedNode *DebugContainerModeling::reportDebugMsg(llvm::StringRef Msg,
132 auto &BR =
C.getBugReporter();
134 std::make_unique<PathSensitiveBugReport>(DebugMsgBugType, Msg, N));
142bool ento::shouldRegisterDebugContainerModeling(
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.
MemRegion - The root abstract class for all memory regions.
The tag upon which the TagVisitor reacts.
bool isInteresting(SymbolRef sym) const
Value representing integer constant.
Represents symbolic expression that isn't a location.
const ContainerData * getContainerData(ProgramStateRef State, const MemRegion *Cont)
The JSON file list parser is used to communicate input to InstallAPI.