The include scanner also returns the primary source file in its output,
so we don't need to go looking for that in the declared include directories.
RELNOTES: None.
PiperOrigin-RevId: 211381758
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompileAction.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompileAction.java
index 69a8890..a028a5d 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompileAction.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompileAction.java
@@ -390,6 +390,9 @@
// anyway. Not having to look at them here saves us from requiring and ArtifactExpander, which
// actionExecutionContext doesn't have at this point. This only works as long as mandatory
// inputs do not contain headers that are built into a module.
+ for (Artifact source : getIncludeScannerSources()) {
+ undeclaredHeaders.remove(source);
+ }
for (Artifact header : ccCompilationContext.getDeclaredIncludeSrcs()) {
undeclaredHeaders.remove(header);
}