Skip to content

Commit 7ea50f4

Browse files
eupharinaresistor
authored andcommitted
[CHERI_CSA] AllocationChecker: move static and heap allocation to new BugType
1 parent 10f0fa0 commit 7ea50f4

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ using namespace cheri;
2828
namespace {
2929

3030
class AllocationChecker : public Checker<check::PostStmt<CastExpr>> {
31-
BugType BT_1{this, "Allocation partitioning", "CHERI portability"};
31+
BugType BT_Default{this, "Allocation partitioning", "CHERI portability"};
32+
BugType BT_KnownReg{this, "Heap or static allocation partitioning",
33+
"CHERI portability"};
3234

3335
class AllocPartitionBugVisitor : public BugReporterVisitor {
3436
public:
@@ -119,7 +121,10 @@ ExplodedNode *AllocationChecker::emitAllocationPartitionWarning(
119121
llvm::raw_svector_ostream OS(Buf);
120122
OS << "Allocation partition: ";
121123
describeCast(OS, CE, C.getASTContext().getLangOpts());
122-
auto R = std::make_unique<PathSensitiveBugReport>(BT_1, OS.str(), ErrNode);
124+
const MemSpaceRegion *MemSpace = MR->getMemorySpace();
125+
bool KnownReg = isa<HeapSpaceRegion, GlobalsSpaceRegion>(MemSpace);
126+
auto R = std::make_unique<PathSensitiveBugReport>(
127+
KnownReg ? BT_KnownReg : BT_Default, OS.str(), ErrNode);
123128
R->addVisitor(std::make_unique<AllocPartitionBugVisitor>(MR));
124129
C.emitReport(std::move(R));
125130
return ErrNode;

0 commit comments

Comments
 (0)