Skip to content

Commit c6bab96

Browse files
eupharinaresistor
authored andcommitted
[CHERI_CSA] AllocationChecker: disable for non-purecap
1 parent d48dc9c commit c6bab96

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

clang/lib/StaticAnalyzer/Checkers/CHERI/AllocationChecker.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,9 @@ ExplodedNode *AllocationChecker::emitAllocationPartitionWarning(
225225

226226
void AllocationChecker::checkPostStmt(const CastExpr *CE,
227227
CheckerContext &C) const {
228+
if (!isPureCapMode(C.getASTContext()))
229+
return;
230+
228231
if (CE->getCastKind() != CK_BitCast)
229232
return;
230233
SVal SrcVal = C.getSVal(CE->getSubExpr());
@@ -295,6 +298,9 @@ void AllocationChecker::checkPostStmt(const CastExpr *CE,
295298

296299
void AllocationChecker::checkPreCall(const CallEvent &Call,
297300
CheckerContext &C) const {
301+
if (!isPureCapMode(C.getASTContext()))
302+
return;
303+
298304
if (IgnoreFnSet.contains(Call) || CheriBoundsFnSet.contains(Call))
299305
return;
300306

@@ -335,6 +341,9 @@ void AllocationChecker::checkPreCall(const CallEvent &Call,
335341

336342
void AllocationChecker::checkPostCall(const CallEvent &Call,
337343
CheckerContext &C) const {
344+
if (!isPureCapMode(C.getASTContext()))
345+
return;
346+
338347
if (!CheriBoundsFnSet.contains(Call))
339348
return;
340349
const MemRegion *MR = C.getSVal(Call.getArgExpr(0)).getAsRegion();
@@ -354,6 +363,9 @@ void AllocationChecker::checkPostCall(const CallEvent &Call,
354363

355364
void AllocationChecker::checkBind(SVal L, SVal V, const Stmt *S,
356365
CheckerContext &C) const {
366+
if (!isPureCapMode(C.getASTContext()))
367+
return;
368+
357369
const MemRegion *Dst = L.getAsRegion();
358370
if (!Dst || !isa<FieldRegion>(Dst))
359371
return;
@@ -375,6 +387,9 @@ void AllocationChecker::checkBind(SVal L, SVal V, const Stmt *S,
375387

376388
void AllocationChecker::checkEndFunction(const ReturnStmt *RS,
377389
CheckerContext &C) const {
390+
if (!isPureCapMode(C.getASTContext()))
391+
return;
392+
378393
if (!RS)
379394
return;
380395
const Expr *RV = RS->getRetValue();

0 commit comments

Comments
 (0)