24using namespace iterator;
28class DebugContainerModeling
31 std::unique_ptr<BugType> DebugMsgBugType;
33 template <
typename Getter>
40 typedef void (DebugContainerModeling::*FnCheck)(
const CallExpr *,
44 {{{
"clang_analyzer_container_begin"}, 1},
45 &DebugContainerModeling::analyzerContainerBegin},
46 {{{
"clang_analyzer_container_end"}, 1},
47 &DebugContainerModeling::analyzerContainerEnd},
51 DebugContainerModeling();
58DebugContainerModeling::DebugContainerModeling() {
59 DebugMsgBugType.reset(
60 new BugType(
this,
"Checking analyzer assumptions",
"debug",
66 const auto *CE = dyn_cast_or_null<CallExpr>(
Call.getOriginExpr());
70 const FnCheck *Handler = Callbacks.lookup(
Call);
74 (this->**Handler)(CE,
C);
78template <
typename Getter>
79void DebugContainerModeling::analyzerContainerDataField(
const CallExpr *CE,
83 reportDebugMsg(
"Missing container argument",
C);
87 auto State =
C.getState();
94 State = State->BindExpr(CE,
C.getLocationContext(),
100 const NoteTag *InterestingTag =
104 BR.markInteresting(Cont);
108 C.addTransition(State, InterestingTag);
114 auto &BVF =
C.getSValBuilder().getBasicValueFactory();
115 State = State->BindExpr(CE,
C.getLocationContext(),
119void DebugContainerModeling::analyzerContainerBegin(
const CallExpr *CE,
126void DebugContainerModeling::analyzerContainerEnd(
const CallExpr *CE,
133ExplodedNode *DebugContainerModeling::reportDebugMsg(llvm::StringRef Msg,
139 auto &BR =
C.getBugReporter();
140 BR.emitReport(std::make_unique<PathSensitiveBugReport>(*DebugMsgBugType,
149bool 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)
SymbolRef getBegin() const