[clang] [HLSL] Strict Availability Diagnostics (PR #93860)
Justin Bogner via cfe-commits
cfe-commits at lists.llvm.org
Fri May 31 10:20:03 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;
+ }
----------------
bogner wrote:
I think it would be clearer/simpler to move this logic into `shouldDiagnoseAvailabilityByDefault`, which would mean the later parts of this function don't need to know about the LangOpts
https://github.com/llvm/llvm-project/pull/93860
More information about the cfe-commits
mailing list