Skip to content

Commit 346a7bf

Browse files
eupharinaresistor
authored andcommitted
[CHERI_CSA] AllocationChecker: suppress for free
1 parent ccc3af1 commit 346a7bf

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

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

Lines changed: 8 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
using namespace clang;
2627
using namespace ento;
@@ -42,6 +43,10 @@ class AllocationChecker
4243
BugType BT_KnownReg{this, "Heap or static allocation partitioning",
4344
"CHERI portability"};
4445

46+
const CallDescriptionSet IgnoreFnSet = {
47+
{{CDM::SimpleFunc, {"free"}, 1}},
48+
};
49+
4550
class AllocPartitionBugVisitor : public BugReporterVisitor {
4651
public:
4752
AllocPartitionBugVisitor(const MemRegion *P, const MemRegion *A)
@@ -253,6 +258,9 @@ void AllocationChecker::checkPostStmt(const CastExpr *CE,
253258

254259
void AllocationChecker::checkPreCall(const CallEvent &Call,
255260
CheckerContext &C) const {
261+
if (IgnoreFnSet.contains(Call))
262+
return;
263+
256264
ProgramStateRef State = C.getState();
257265
ExplodedNode *N = nullptr;
258266
bool Updated = false;

0 commit comments

Comments
 (0)