Correct isThirdParty check

Previously, isThirdParty check was over-selecting for third-party-ness,
the only non-third-party paths were those explicitly excluded from
typically third party directories, results in ~all code being considered
third party.

Updated test to ensure bionic is not considered third party, which fails
without this change.

Test: go soong tests
Change-Id: Id371aaad2ceef2b3163384fa84712397877cbe90
diff --git a/cc/cc_test.go b/cc/cc_test.go
index dd51fe8..84c3a86 100644
--- a/cc/cc_test.go
+++ b/cc/cc_test.go
@@ -3955,10 +3955,13 @@
 		`, lib, lib)
 	}
 
-	ctx := PrepareForIntegrationTestWithCc.RunTestWithBp(t, bp)
+	ctx := android.GroupFixturePreparers(
+		PrepareForIntegrationTestWithCc,
+		android.FixtureAddTextFile("external/foo/Android.bp", bp),
+	).RunTest(t)
 	// Use the arm variant instead of the arm64 variant so that it gets headers from
 	// ndk_libandroid_support to test LateStaticLibs.
-	cflags := ctx.ModuleForTests("libfoo", "android_arm_armv7-a-neon_sdk_static").Output("obj/foo.o").Args["cFlags"]
+	cflags := ctx.ModuleForTests("libfoo", "android_arm_armv7-a-neon_sdk_static").Output("obj/external/foo/foo.o").Args["cFlags"]
 
 	var includes []string
 	flags := strings.Split(cflags, " ")
@@ -3981,32 +3984,32 @@
 		"${config.ArmToolchainCflags}",
 		"${config.ArmArmv7ANeonCflags}",
 		"${config.ArmGenericCflags}",
-		"android_arm_export_include_dirs",
-		"lib32_export_include_dirs",
-		"arm_export_include_dirs",
-		"android_export_include_dirs",
-		"linux_export_include_dirs",
-		"export_include_dirs",
-		"android_arm_local_include_dirs",
-		"lib32_local_include_dirs",
-		"arm_local_include_dirs",
-		"android_local_include_dirs",
-		"linux_local_include_dirs",
-		"local_include_dirs",
-		".",
-		"libheader1",
-		"libheader2",
-		"libwhole1",
-		"libwhole2",
-		"libstatic1",
-		"libstatic2",
-		"libshared1",
-		"libshared2",
-		"liblinux",
-		"libandroid",
-		"libarm",
-		"lib32",
-		"libandroid_arm",
+		"external/foo/android_arm_export_include_dirs",
+		"external/foo/lib32_export_include_dirs",
+		"external/foo/arm_export_include_dirs",
+		"external/foo/android_export_include_dirs",
+		"external/foo/linux_export_include_dirs",
+		"external/foo/export_include_dirs",
+		"external/foo/android_arm_local_include_dirs",
+		"external/foo/lib32_local_include_dirs",
+		"external/foo/arm_local_include_dirs",
+		"external/foo/android_local_include_dirs",
+		"external/foo/linux_local_include_dirs",
+		"external/foo/local_include_dirs",
+		"external/foo",
+		"external/foo/libheader1",
+		"external/foo/libheader2",
+		"external/foo/libwhole1",
+		"external/foo/libwhole2",
+		"external/foo/libstatic1",
+		"external/foo/libstatic2",
+		"external/foo/libshared1",
+		"external/foo/libshared2",
+		"external/foo/liblinux",
+		"external/foo/libandroid",
+		"external/foo/libarm",
+		"external/foo/lib32",
+		"external/foo/libandroid_arm",
 		"defaults/cc/common/ndk_libc++_shared",
 		"defaults/cc/common/ndk_libandroid_support",
 		"out/soong/ndk/sysroot/usr/include",
diff --git a/cc/compiler.go b/cc/compiler.go
index 34ac47a..e19efd5 100644
--- a/cc/compiler.go
+++ b/cc/compiler.go
@@ -692,8 +692,9 @@
 				return false
 			}
 		}
+		return true
 	}
-	return true
+	return false
 }
 
 // Properties for rust_bindgen related to generating rust bindings.
diff --git a/cc/compiler_test.go b/cc/compiler_test.go
index c301388..a3ee4a6 100644
--- a/cc/compiler_test.go
+++ b/cc/compiler_test.go
@@ -19,23 +19,24 @@
 )
 
 func TestIsThirdParty(t *testing.T) {
-	shouldFail := []string{
+	thirdPartyPaths := []string{
 		"external/foo/",
 		"vendor/bar/",
 		"hardware/underwater_jaguar/",
 	}
-	shouldPass := []string{
+	nonThirdPartyPaths := []string{
 		"vendor/google/cts/",
 		"hardware/google/pixel",
 		"hardware/interfaces/camera",
 		"hardware/ril/supa_ril",
+		"bionic/libc",
 	}
-	for _, path := range shouldFail {
+	for _, path := range thirdPartyPaths {
 		if !isThirdParty(path) {
 			t.Errorf("Expected %s to be considered third party", path)
 		}
 	}
-	for _, path := range shouldPass {
+	for _, path := range nonThirdPartyPaths {
 		if isThirdParty(path) {
 			t.Errorf("Expected %s to *not* be considered third party", path)
 		}