Add to cflags in compilerFlags()

These compiler flags weren't being properly added to ToolingCFlags,
which was causing clang-tidy to complain a lot about incompatible
redeclarations of library functions. Moving them to compilerFlags()
causes them to be added to ToolingCFlags.

Bug: None
Test: mma in bionic/. clang-tidy now shows 7,142 fewer high-severity
warnings.

Change-Id: If5148858d9db143a3dd9b0ce6c970258ec4ff9cb
diff --git a/cc/ndk_library.go b/cc/ndk_library.go
index 5765aa9..dbfc5be 100644
--- a/cc/ndk_library.go
+++ b/cc/ndk_library.go
@@ -242,6 +242,25 @@
 	ndkMigratedLibs = append(ndkMigratedLibs, name)
 }
 
+func addStubLibraryCompilerFlags(flags Flags) Flags {
+	flags.CFlags = append(flags.CFlags,
+		// We're knowingly doing some otherwise unsightly things with builtin
+		// functions here. We're just generating stub libraries, so ignore it.
+		"-Wno-incompatible-library-redeclaration",
+		"-Wno-builtin-requires-header",
+		"-Wno-invalid-noreturn",
+		// These libraries aren't actually used. Don't worry about unwinding
+		// (avoids the need to link an unwinder into a fake library).
+		"-fno-unwind-tables",
+	)
+	return flags
+}
+
+func (stub *stubDecorator) compilerFlags(ctx ModuleContext, flags Flags) Flags {
+	flags = stub.baseCompiler.compilerFlags(ctx, flags)
+	return addStubLibraryCompilerFlags(flags)
+}
+
 func compileStubLibrary(ctx ModuleContext, flags Flags, symbolFile, apiLevel, vndk string) (Objects, android.ModuleGenPath) {
 	arch := ctx.Arch().ArchType.String()
 
@@ -263,18 +282,6 @@
 		},
 	})
 
-	flags.CFlags = append(flags.CFlags,
-		// We're knowingly doing some otherwise unsightly things with builtin
-		// functions here. We're just generating stub libraries, so ignore it.
-		"-Wno-incompatible-library-redeclaration",
-		"-Wno-builtin-requires-header",
-		"-Wno-invalid-noreturn",
-
-		// These libraries aren't actually used. Don't worry about unwinding
-		// (avoids the need to link an unwinder into a fake library).
-		"-fno-unwind-tables",
-	)
-
 	subdir := ""
 	srcs := []android.Path{stubSrcPath}
 	return compileObjs(ctx, flagsToBuilderFlags(flags), subdir, srcs, nil), versionScriptPath