Convert trivial TopDown mutators to BottomUp
Many TopDown mutators can be easily converted to BottomUp mutators,
which are easier to handle for incremental and partial analysis.
Bug: 367784740
Test: all soong tests pass
Test: no change to build.ninja
Flag: EXEMPT refactor
Change-Id: I82955e844ed0eb6680854678c0744ac5398eb7ba
diff --git a/cc/cc.go b/cc/cc.go
index 6e16142..96795d3 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -59,10 +59,10 @@
san.registerMutators(ctx)
}
- ctx.TopDown("sanitize_runtime_deps", sanitizerRuntimeDepsMutator).Parallel()
+ ctx.BottomUp("sanitize_runtime_deps", sanitizerRuntimeDepsMutator).Parallel()
ctx.BottomUp("sanitize_runtime", sanitizerRuntimeMutator).Parallel()
- ctx.TopDown("fuzz_deps", fuzzMutatorDeps)
+ ctx.BottomUp("fuzz_deps", fuzzMutatorDeps)
ctx.Transition("coverage", &coverageTransitionMutator{})
@@ -73,7 +73,7 @@
ctx.Transition("lto", <oTransitionMutator{})
ctx.BottomUp("check_linktype", checkLinkTypeMutator).Parallel()
- ctx.TopDown("double_loadable", checkDoubleLoadableLibraries).Parallel()
+ ctx.BottomUp("double_loadable", checkDoubleLoadableLibraries).Parallel()
})
ctx.FinalDepsMutators(func(ctx android.RegisterMutatorsContext) {
@@ -2783,7 +2783,7 @@
// If a library has a vendor variant and is a (transitive) dependency of an LLNDK library,
// it is subject to be double loaded. Such lib should be explicitly marked as double_loadable: true
// or as vndk-sp (vndk: { enabled: true, support_system_process: true}).
-func checkDoubleLoadableLibraries(ctx android.TopDownMutatorContext) {
+func checkDoubleLoadableLibraries(ctx android.BottomUpMutatorContext) {
check := func(child, parent android.Module) bool {
to, ok := child.(*Module)
if !ok {
diff --git a/cc/fuzz.go b/cc/fuzz.go
index d9e221b..3f21bc6 100644
--- a/cc/fuzz.go
+++ b/cc/fuzz.go
@@ -57,7 +57,7 @@
return []interface{}{&fuzzer.Properties}
}
-func fuzzMutatorDeps(mctx android.TopDownMutatorContext) {
+func fuzzMutatorDeps(mctx android.BottomUpMutatorContext) {
currentModule, ok := mctx.Module().(*Module)
if !ok {
return
diff --git a/cc/sanitize.go b/cc/sanitize.go
index 7b0652c..b10a3dd 100644
--- a/cc/sanitize.go
+++ b/cc/sanitize.go
@@ -176,7 +176,7 @@
switch t {
case cfi, Hwasan, Asan, tsan, Fuzzer, scs, Memtag_stack:
sanitizer := &sanitizerSplitMutator{t}
- ctx.TopDown(t.variationName()+"_markapexes", sanitizer.markSanitizableApexesMutator)
+ ctx.BottomUp(t.variationName()+"_markapexes", sanitizer.markSanitizableApexesMutator)
ctx.Transition(t.variationName(), sanitizer)
case Memtag_heap, Memtag_globals, intOverflow:
// do nothing
@@ -1153,7 +1153,7 @@
// If an APEX is sanitized or not depends on whether it contains at least one
// sanitized module. Transition mutators cannot propagate information up the
// dependency graph this way, so we need an auxiliary mutator to do so.
-func (s *sanitizerSplitMutator) markSanitizableApexesMutator(ctx android.TopDownMutatorContext) {
+func (s *sanitizerSplitMutator) markSanitizableApexesMutator(ctx android.BottomUpMutatorContext) {
if sanitizeable, ok := ctx.Module().(Sanitizeable); ok {
enabled := sanitizeable.IsSanitizerEnabled(ctx.Config(), s.sanitizer.name())
ctx.VisitDirectDeps(func(dep android.Module) {
@@ -1355,7 +1355,7 @@
}
// Propagate the ubsan minimal runtime dependency when there are integer overflow sanitized static dependencies.
-func sanitizerRuntimeDepsMutator(mctx android.TopDownMutatorContext) {
+func sanitizerRuntimeDepsMutator(mctx android.BottomUpMutatorContext) {
// Change this to PlatformSanitizable when/if non-cc modules support ubsan sanitizers.
if c, ok := mctx.Module().(*Module); ok && c.sanitize != nil {
if c.sanitize.Properties.ForceDisable {