Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions clang/lib/StaticAnalyzer/Checkers/PointerAlignmentChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,11 @@ int getTrailingZerosCount(const SVal &V, ProgramStateRef State,
if (V.isUnknownOrUndef())
return -1;

// Sealed capabilities cannot be dereferenced, and any type-punning
// will be dynamically checked during unsealing.
if (V.getType(ASTCtx)->isCHERISealedCapabilityType(ASTCtx))
return -1;

if (V.isConstant()) {
if (auto LV = V.getAs<loc::ConcreteInt>())
return LV->getValue()->countTrailingZeros();
Expand Down
6 changes: 6 additions & 0 deletions clang/test/Analysis/pointer-alignment.c
Original file line number Diff line number Diff line change
Expand Up @@ -214,3 +214,9 @@ void write_to_first_member(struct AlignedParentStruct *chunk) {
*(long long*)(&chunk->a) = 0;
}

// ----
long long * __sealed_capability sealed_cast(int * __sealed_capability in) {
// No warnings for sealed capabilities, since they will be effectively dynamically
// verified when unsealed.
return (long long * __sealed_capability)in;
}