Skip to content

Commit 54ace79

Browse files
committed
[CHERI_CSA] AllocationChecker: disable for non-purecap
1 parent 9041b11 commit 54ace79

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
@@ -248,6 +248,9 @@ ExplodedNode *AllocationChecker::emitAllocationPartitionWarning(
248248

249249
void AllocationChecker::checkPostStmt(const CastExpr *CE,
250250
CheckerContext &C) const {
251+
if (!isPureCapMode(C.getASTContext()))
252+
return;
253+
251254
if (CE->getCastKind() != CK_BitCast)
252255
return;
253256
SVal SrcVal = C.getSVal(CE->getSubExpr());
@@ -318,6 +321,9 @@ void AllocationChecker::checkPostStmt(const CastExpr *CE,
318321

319322
void AllocationChecker::checkPreCall(const CallEvent &Call,
320323
CheckerContext &C) const {
324+
if (!isPureCapMode(C.getASTContext()))
325+
return;
326+
321327
if (IgnoreFnSet.contains(Call) || CheriBoundsFnSet.contains(Call))
322328
return;
323329

@@ -360,6 +366,9 @@ void AllocationChecker::checkPreCall(const CallEvent &Call,
360366

361367
void AllocationChecker::checkPostCall(const CallEvent &Call,
362368
CheckerContext &C) const {
369+
if (!isPureCapMode(C.getASTContext()))
370+
return;
371+
363372
if (!CheriBoundsFnSet.contains(Call))
364373
return;
365374
const MemRegion *MR = C.getSVal(Call.getArgExpr(0)).getAsRegion();
@@ -379,6 +388,9 @@ void AllocationChecker::checkPostCall(const CallEvent &Call,
379388

380389
void AllocationChecker::checkBind(SVal L, SVal V, const Stmt *S,
381390
CheckerContext &C) const {
391+
if (!isPureCapMode(C.getASTContext()))
392+
return;
393+
382394
const MemRegion *Dst = L.getAsRegion();
383395
if (!Dst || !isa<FieldRegion>(Dst))
384396
return;
@@ -400,6 +412,9 @@ void AllocationChecker::checkBind(SVal L, SVal V, const Stmt *S,
400412

401413
void AllocationChecker::checkEndFunction(const ReturnStmt *RS,
402414
CheckerContext &C) const {
415+
if (!isPureCapMode(C.getASTContext()))
416+
return;
417+
403418
if (!RS)
404419
return;
405420
const Expr *RV = RS->getRetValue();

0 commit comments

Comments
 (0)