[clang] [HLSL] Strict Availability Diagnostics (PR #93860)
Helena Kotas via cfe-commits
cfe-commits at lists.llvm.org
Mon Jun 3 11:54:58 PDT 2024
================
@@ -834,34 +829,55 @@ void DiagnoseUnguardedAvailability::DiagnoseDeclAvailability(
OffendingDecl))
return;
- // We would like to emit the diagnostic even if -Wunguarded-availability is
- // not specified for deployment targets >= to iOS 11 or equivalent or
- // for declarations that were introduced in iOS 11 (macOS 10.13, ...) or
- // later.
- bool UseNewDiagKind = shouldDiagnoseAvailabilityByDefault(
- SemaRef.Context,
- SemaRef.Context.getTargetInfo().getPlatformMinVersion(), Introduced);
-
const TargetInfo &TI = SemaRef.getASTContext().getTargetInfo();
+
+ // In HLSL, emit diagnostic here 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).
+ const LangOptions &LandOpts = SemaRef.getLangOpts();
+ if (LandOpts.HLSL) {
+ if (!LandOpts.HLSLStrictAvailability ||
+ (AA->getEnvironment() != nullptr &&
+ TI.getTriple().getEnvironment() ==
+ llvm::Triple::EnvironmentType::Library))
+ return;
+ }
----------------
hekota wrote:
`shouldDiagnoseAvailabilityByDefault` just determines which diag id to use, not wherther to skip the diagnostic. But I can move it to `ShouldDiagnoseAvailabilityInContext`.
https://github.com/llvm/llvm-project/pull/93860
More information about the cfe-commits
mailing list