[clang] [HLSL] Strict Availability Diagnostics (PR #93860)
Damyan Pepper via cfe-commits
cfe-commits at lists.llvm.org
Mon Jun 17 16:13:55 PDT 2024
================
@@ -157,6 +157,18 @@ static bool ShouldDiagnoseAvailabilityInContext(
}
}
+ // In HLSL, emit diagnostic during parsing only if the diagnostic
+ // mode is set to strict (-fhlsl-strict-availability), and either the decl
+ // availability is not restricted to a specific environment/shader stage,
+ // or the target stage is known (= it is not shader library).
+ if (S.getLangOpts().HLSL) {
+ if (!S.getLangOpts().HLSLStrictAvailability ||
+ (DeclEnv != nullptr &&
+ S.getASTContext().getTargetInfo().getTriple().getEnvironment() ==
+ llvm::Triple::EnvironmentType::Library))
+ return false;
+ }
----------------
damyanp wrote:
Nit, and maybe not worth doing, but I had to read this a few times because the comment is written in the opposite way to the code.
```suggestion
if (S.getLangOpts().HLSL) {
bool emitDiagnostics = S.getLangOpts().HLSLStrictAvailability && (
DeclEnv == nullptr ||
S.getASTContext().getTargetInfo().getTriple().getEnvironment() !=
llvm::Triple::EnvironmentType::Library);
if (!emitDiagnostics)
return false;
}
```
https://github.com/llvm/llvm-project/pull/93860
More information about the cfe-commits
mailing list