Skip to content

Commit b926eed

Browse files
eupharinaresistor
authored andcommitted
[CHERI_CSA] AllocationChecker: move static and heap allocation to new BugType
1 parent a072f4f commit b926eed

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

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

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

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

3436
class AllocPartitionBugVisitor : public BugReporterVisitor {
3537
public:
@@ -120,8 +122,10 @@ ExplodedNode *AllocationChecker::emitAllocationPartitionWarning(
120122
llvm::raw_svector_ostream OS(Buf);
121123
OS << "Allocation partition: ";
122124
describeCast(OS, CE, C.getASTContext().getLangOpts());
125+
const MemSpaceRegion *MemSpace = MR->getMemorySpace();
126+
bool KnownReg = isa<HeapSpaceRegion, GlobalsSpaceRegion>(MemSpace);
123127
auto R = std::make_unique<PathSensitiveBugReport>(
124-
BT_1, OS.str(), ErrNode);
128+
KnownReg ? BT_KnownReg : BT_Default, OS.str(), ErrNode);
125129
R->addVisitor(std::make_unique<AllocPartitionBugVisitor>(MR));
126130
C.emitReport(std::move(R));
127131
return ErrNode;

0 commit comments

Comments
 (0)