Add clang-tidy support

For every file which we can run clang-tidy (C/C++ clang-built), we add a
new build node that depends on the object file (since clang-tidy does
not export a depfile), and is depended on by the link step. This is
better than how we're doing it in make, since calling tidy can be turned
on or off without needing to rebuild the object files.

This does not attempt to port WITH_TIDY_ONLY from Make, since the way
that it works is broken (due to the lack of a depfile).

Bug: 32244182
Test: WITH_TIDY=true mmma -j bionic/libc
Test: ./soong (Setting ClangTidy: true)
Change-Id: I40bbb5bb00d292d72bf1c293b93080b5f9f6d8ea
diff --git a/cc/cc.go b/cc/cc.go
index c2884ac..b6e98b1 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -100,9 +100,11 @@
 	protoFlags  []string // Flags that apply to proto source files
 	LdFlags     []string // Flags that apply to linker command lines
 	libFlags    []string // Flags to add libraries early to the link order
+	TidyFlags   []string // Flags that apply to clang-tidy
 
 	Toolchain config.Toolchain
 	Clang     bool
+	Tidy      bool
 
 	RequiredInstructionSet string
 	DynamicLinker          string
@@ -368,6 +370,9 @@
 
 func newModule(hod android.HostOrDeviceSupported, multilib android.Multilib) *Module {
 	module := newBaseModule(hod, multilib)
+	module.features = []feature{
+		&tidyFeature{},
+	}
 	module.stl = &stl{}
 	module.sanitize = &sanitize{}
 	return module
@@ -948,6 +953,7 @@
 		&SanitizeProperties{},
 		&StripProperties{},
 		&InstallerProperties{},
+		&TidyProperties{},
 	)
 
 	return android.InitDefaultsModule(module, module, props...)