Skip to content

Commit 890c9d5

Browse files
eupharinaresistor
authored andcommitted
[CHERI_CSA] AllocationChecker: suppress for free
1 parent ed1e296 commit 890c9d5

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
2222
#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
2323
#include "clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h"
24+
#include <clang/StaticAnalyzer/Core/PathSensitive/CallDescription.h>
2425

2526

2627
using namespace clang;
@@ -49,6 +50,11 @@ class AllocationChecker : public Checker<check::PostStmt<CastExpr>,
4950
BugType BT_KnownReg{this, "Heap or static allocation partitioning",
5051
"CHERI portability"};
5152

53+
const CallDescriptionSet IgnoreFnSet = {
54+
{{CDM::SimpleFunc, {"free"}, 1}},
55+
};
56+
57+
5258
class AllocPartitionBugVisitor : public BugReporterVisitor {
5359
public:
5460
AllocPartitionBugVisitor(const MemRegion *P, const MemRegion *A)
@@ -261,6 +267,9 @@ void AllocationChecker::checkPostStmt(const CastExpr *CE,
261267

262268
void AllocationChecker::checkPreCall(const CallEvent &Call,
263269
CheckerContext &C) const {
270+
if (IgnoreFnSet.contains(Call))
271+
return;
272+
264273
ProgramStateRef State = C.getState();
265274
ExplodedNode *N = nullptr;
266275
bool Updated = false;

0 commit comments

Comments
 (0)