Iterate over sanitizers
Test: go test soong tests
Change-Id: If89b7d0b04cad79b42a08504d4fcff36e914b7a4
diff --git a/cc/sanitize.go b/cc/sanitize.go
index 0ed0d47..defe8fd 100644
--- a/cc/sanitize.go
+++ b/cc/sanitize.go
@@ -79,12 +79,23 @@
Hwasan
tsan
intOverflow
- cfi
scs
Fuzzer
memtag_heap
+ cfi // cfi is last to prevent it running before incompatible mutators
)
+var Sanitizers = []SanitizerType{
+ Asan,
+ Hwasan,
+ tsan,
+ intOverflow,
+ scs,
+ Fuzzer,
+ memtag_heap,
+ cfi, // cfi is last to prevent it running before incompatible mutators
+}
+
// Name of the sanitizer variation for this sanitizer type
func (t SanitizerType) variationName() string {
switch t {
@@ -133,6 +144,18 @@
}
}
+func (t SanitizerType) registerMutators(ctx android.RegisterMutatorsContext) {
+ switch t {
+ case Asan, Hwasan, Fuzzer, scs, tsan, cfi:
+ ctx.TopDown(t.variationName()+"_deps", sanitizerDepsMutator(t))
+ ctx.BottomUp(t.variationName(), sanitizerMutator(t))
+ case memtag_heap, intOverflow:
+ // do nothing
+ default:
+ panic(fmt.Errorf("unknown SanitizerType %d", t))
+ }
+}
+
func (*Module) SanitizerSupported(t SanitizerType) bool {
switch t {
case Asan: