@@ -215,6 +215,9 @@ ExplodedNode *AllocationChecker::emitAllocationPartitionWarning(
215215
216216void AllocationChecker::checkPostStmt (const CastExpr *CE,
217217 CheckerContext &C) const {
218+ if (!isPureCapMode (C.getASTContext ()))
219+ return ;
220+
218221 if (CE->getCastKind () != CK_BitCast)
219222 return ;
220223 SVal SrcVal = C.getSVal (CE->getSubExpr ());
@@ -285,6 +288,9 @@ void AllocationChecker::checkPostStmt(const CastExpr *CE,
285288
286289void AllocationChecker::checkPreCall (const CallEvent &Call,
287290 CheckerContext &C) const {
291+ if (!isPureCapMode (C.getASTContext ()))
292+ return ;
293+
288294 if (IgnoreFnSet.contains (Call) || CheriBoundsFnSet.contains (Call))
289295 return ;
290296
@@ -332,6 +338,9 @@ void AllocationChecker::checkPreCall(const CallEvent &Call,
332338
333339void AllocationChecker::checkPostCall (const CallEvent &Call,
334340 CheckerContext &C) const {
341+ if (!isPureCapMode (C.getASTContext ()))
342+ return ;
343+
335344 if (!CheriBoundsFnSet.contains (Call))
336345 return ;
337346 const MemRegion *MR = C.getSVal (Call.getArgExpr (0 )).getAsRegion ();
@@ -351,6 +360,9 @@ void AllocationChecker::checkPostCall(const CallEvent &Call,
351360
352361void AllocationChecker::checkBind (SVal L, SVal V, const Stmt *S,
353362 CheckerContext &C) const {
363+ if (!isPureCapMode (C.getASTContext ()))
364+ return ;
365+
354366 const MemRegion *Dst = L.getAsRegion ();
355367 if (!Dst || !isa<FieldRegion>(Dst))
356368 return ;
@@ -372,6 +384,9 @@ void AllocationChecker::checkBind(SVal L, SVal V, const Stmt *S,
372384
373385void AllocationChecker::checkEndFunction (const ReturnStmt *RS,
374386 CheckerContext &C) const {
387+ if (!isPureCapMode (C.getASTContext ()))
388+ return ;
389+
375390 if (!RS)
376391 return ;
377392 const Expr *RV = RS->getRetValue ();
0 commit comments