Remove flags rejected by RBE input processor

* This is a temporary work around until the RBE input processor
  can handle those flags.
* It's okay to remove some cflags in clang-tidy command
  if they do not affect tidy check results.

Bug: 248371171
Test: enable RBE; RBE_CLANG_TIDY_EXEC_STRATEGY=remote; make tidy-soong_subset
Change-Id: If499bd7e1f0f89ccc3b7f7df7d67cfc64dc67028
diff --git a/cc/builder.go b/cc/builder.go
index 0bea9da..39f7dc3 100644
--- a/cc/builder.go
+++ b/cc/builder.go
@@ -672,11 +672,16 @@
 			tidyCmd := "${config.ClangBin}/clang-tidy"
 
 			rule := clangTidy
+			reducedCFlags := moduleFlags
 			if ctx.Config().UseRBE() && ctx.Config().IsEnvTrue("RBE_CLANG_TIDY") {
 				rule = clangTidyRE
+				// b/248371171, work around RBE input processor problem
+				// some cflags rejected by input processor, but usually
+				// do not affect included files or clang-tidy
+				reducedCFlags = config.TidyReduceCFlags(reducedCFlags)
 			}
 
-			sharedCFlags := shareFlags("cFlags", moduleFlags)
+			sharedCFlags := shareFlags("cFlags", reducedCFlags)
 			srcRelPath := srcFile.Rel()
 
 			// Add the .tidy rule