Skip to content

Commit

Permalink
Consider a compile action to have loose headers if it has textual hea…
Browse files Browse the repository at this point in the history
…ders and loose headers checking is enabled.

Textual headers may loosely include other header files even when layering check is enabled.

PiperOrigin-RevId: 386489066
  • Loading branch information
justinhorvitz authored and copybara-github committed Jul 23, 2021
1 parent e1f2e3d commit 6308317
Showing 1 changed file with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
import com.google.devtools.build.lib.profiler.SilentCloseable;
import com.google.devtools.build.lib.rules.cpp.CcCommon.CoptsFilter;
import com.google.devtools.build.lib.rules.cpp.CcToolchainFeatures.FeatureConfiguration;
import com.google.devtools.build.lib.rules.cpp.CppConfiguration.HeadersCheckingMode;
import com.google.devtools.build.lib.rules.cpp.IncludeScanner.IncludeScanningHeaderData;
import com.google.devtools.build.lib.server.FailureDetails.CppCompile;
import com.google.devtools.build.lib.server.FailureDetails.CppCompile.Code;
Expand Down Expand Up @@ -1780,13 +1781,13 @@ public boolean hasLooseHeaders() {
// Separated into a helper method so that it can be called from CppCompileActionTemplate.
static boolean hasLooseHeaders(
CcCompilationContext ccCompilationContext, FeatureConfiguration featureConfiguration) {
// Layering check is stricter than hdrs_check = strict, so when it's enabled, there can't be
// loose headers.
return ccCompilationContext
.getHeadersCheckingMode()
.equals(CppConfiguration.HeadersCheckingMode.LOOSE)
&& !(featureConfiguration.isEnabled(CppRuleClasses.LAYERING_CHECK)
&& featureConfiguration.isEnabled(CppRuleClasses.PARSE_HEADERS));
if (ccCompilationContext.getHeadersCheckingMode() != HeadersCheckingMode.LOOSE) {
return false;
}
// Loose headers may still be included via textual_hdrs even if layering check is enabled.
return !featureConfiguration.isEnabled(CppRuleClasses.LAYERING_CHECK)
|| !featureConfiguration.isEnabled(CppRuleClasses.PARSE_HEADERS)
|| !ccCompilationContext.getTextualHdrs().isEmpty();
}

public CompileCommandLine getCompileCommandLine() {
Expand Down

0 comments on commit 6308317

Please sign in to comment.