Skip to content

Commit 389ce92

Browse files
eupharinaresistor
authored andcommitted
[CHERI_CSA] AllocationChecker: disable for non-purecap
1 parent 1188df4 commit 389ce92

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

215215
void AllocationChecker::checkPostStmt(const CastExpr *CE,
216216
CheckerContext &C) const {
217+
if (!isPureCapMode(C.getASTContext()))
218+
return;
219+
217220
if (CE->getCastKind() != CK_BitCast)
218221
return;
219222
SVal SrcVal = C.getSVal(CE->getSubExpr());
@@ -284,6 +287,9 @@ void AllocationChecker::checkPostStmt(const CastExpr *CE,
284287

285288
void AllocationChecker::checkPreCall(const CallEvent &Call,
286289
CheckerContext &C) const {
290+
if (!isPureCapMode(C.getASTContext()))
291+
return;
292+
287293
if (IgnoreFnSet.contains(Call) || CheriBoundsFnSet.contains(Call))
288294
return;
289295

@@ -331,6 +337,9 @@ void AllocationChecker::checkPreCall(const CallEvent &Call,
331337

332338
void AllocationChecker::checkPostCall(const CallEvent &Call,
333339
CheckerContext &C) const {
340+
if (!isPureCapMode(C.getASTContext()))
341+
return;
342+
334343
if (!CheriBoundsFnSet.contains(Call))
335344
return;
336345
const MemRegion *MR = C.getSVal(Call.getArgExpr(0)).getAsRegion();
@@ -350,6 +359,9 @@ void AllocationChecker::checkPostCall(const CallEvent &Call,
350359

351360
void AllocationChecker::checkBind(SVal L, SVal V, const Stmt *S,
352361
CheckerContext &C) const {
362+
if (!isPureCapMode(C.getASTContext()))
363+
return;
364+
353365
const MemRegion *Dst = L.getAsRegion();
354366
if (!Dst || !isa<FieldRegion>(Dst))
355367
return;
@@ -371,6 +383,9 @@ void AllocationChecker::checkBind(SVal L, SVal V, const Stmt *S,
371383

372384
void AllocationChecker::checkEndFunction(const ReturnStmt *RS,
373385
CheckerContext &C) const {
386+
if (!isPureCapMode(C.getASTContext()))
387+
return;
388+
374389
if (!RS)
375390
return;
376391
const Expr *RV = RS->getRetValue();

0 commit comments

Comments
 (0)