Skip to content

Commit ca354e7

Browse files
eupharinaresistor
authored andcommitted
[CHERI_CSA] AllocationChecker: disable for non-purecap
1 parent 5cfd360 commit ca354e7

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

216216
void 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

286289
void 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

333339
void 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

352361
void 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

373385
void 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

Comments
 (0)