[clang] [HLSL] Strict Availability Diagnostics (PR #93860)

Damyan Pepper via cfe-commits cfe-commits at lists.llvm.org
Mon Jun 17 18:25:40 PDT 2024


================
@@ -536,9 +536,34 @@ DiagnoseHLSLAvailability::FindAvailabilityAttr(const Decl *D) {
 void DiagnoseHLSLAvailability::CheckDeclAvailability(NamedDecl *D,
                                                      const AvailabilityAttr *AA,
                                                      SourceRange Range) {
-  if (ReportOnlyShaderStageIssues && !AA->getEnvironment())
-    return;
 
+  IdentifierInfo *IIEnv = AA->getEnvironment();
+
+  if (!IIEnv) {
+    // The availability attribute does not have environment -> it depends only
+    // on shader model version and not on specific the shader stage.
+
+    // Skip emitting the diagnostics if the diagnostic mode is not set to
+    // strict (-fhlsl-strict-availability) because all relevant diagnostics
+    // were already emitted in the DiagnoseUnguardedAvailability scan
+    // (SemaAvailability.cpp).
+    if (SemaRef.getLangOpts().HLSLStrictAvailability)
+      return;
----------------
damyanp wrote:

> Yes, it skips emitting diagnostic here in strict mode because it has already been emitted in the...

Right, but the comment says it skips emitting the diagnostics if it is _not_ in strict mode.

https://github.com/llvm/llvm-project/pull/93860


More information about the cfe-commits mailing list