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

Helena Kotas via cfe-commits cfe-commits at lists.llvm.org
Mon Jun 17 18:08:48 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;
----------------
hekota wrote:

It's the opposite of the condition in SemaAvailability.cpp:164 which you commented on above.

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


More information about the cfe-commits mailing list