Skip to content

Commit 3548667

Browse files
melvergithub-actions[bot]
authored andcommitted
Automerge: [Clang][CodeGen] Introduce the AllocToken SanitizerKind (#162098)
[ Reland after 7815df1 ("[Clang] Fix brittle print-header-json.c test") ] Introduce the "alloc-token" sanitizer kind, in preparation of wiring it up. Currently this is a no-op, and any attempt to enable it will result in failure: clang: error: unsupported option '-fsanitize=alloc-token' for target 'x86_64-unknown-linux-gnu' In this step we can already wire up the `sanitize_alloc_token` IR attribute where the instrumentation is enabled. Subsequent changes will complete wiring up the AllocToken pass. --- This change is part of the following series: 1. llvm/llvm-project#160131 2. llvm/llvm-project#156838 3. llvm/llvm-project#162098 4. llvm/llvm-project#162099 5. llvm/llvm-project#156839 6. llvm/llvm-project#156840 7. llvm/llvm-project#156841 8. llvm/llvm-project#156842
2 parents 298421a + 8ba7384 commit 3548667

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

clang/include/clang/Basic/Sanitizers.def

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,9 @@ SANITIZER_GROUP("bounds", Bounds, ArrayBounds | LocalBounds)
195195
// Scudo hardened allocator
196196
SANITIZER("scudo", Scudo)
197197

198+
// AllocToken
199+
SANITIZER("alloc-token", AllocToken)
200+
198201
// Magic group, containing all sanitizers. For example, "-fno-sanitize=all"
199202
// can be used to disable all the sanitizers.
200203
SANITIZER_GROUP("all", All, ~SanitizerMask())

clang/lib/CodeGen/CodeGenFunction.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -846,6 +846,8 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, QualType RetTy,
846846
Fn->addFnAttr(llvm::Attribute::SanitizeNumericalStability);
847847
if (SanOpts.hasOneOf(SanitizerKind::Memory | SanitizerKind::KernelMemory))
848848
Fn->addFnAttr(llvm::Attribute::SanitizeMemory);
849+
if (SanOpts.has(SanitizerKind::AllocToken))
850+
Fn->addFnAttr(llvm::Attribute::SanitizeAllocToken);
849851
}
850852
if (SanOpts.has(SanitizerKind::SafeStack))
851853
Fn->addFnAttr(llvm::Attribute::SafeStack);

0 commit comments

Comments
 (0)