@@ -689,27 +689,31 @@ static AvailabilityResult CheckAvailability(ASTContext &Context,
689
689
if (!A->getIntroduced ().empty () &&
690
690
EnclosingVersion < A->getIntroduced ()) {
691
691
IdentifierInfo *IIEnv = A->getEnvironment ();
692
- StringRef TargetEnv =
693
- Context. getTargetInfo (). getTriple () .getEnvironmentName ();
694
- StringRef EnvName = llvm::Triple::getEnvironmentTypeName (
695
- Context. getTargetInfo (). getTriple () .getEnvironment ());
696
- // Matching environment or no environment on attribute
697
- if (!IIEnv || (!TargetEnv. empty () && IIEnv->getName () == TargetEnv)) {
692
+ auto &Triple = Context. getTargetInfo (). getTriple ();
693
+ StringRef TargetEnv = Triple .getEnvironmentName ();
694
+ StringRef EnvName =
695
+ llvm::Triple::getEnvironmentTypeName (Triple .getEnvironment ());
696
+ // Matching environment or no environment on attribute.
697
+ if (!IIEnv || (Triple. hasEnvironment () && IIEnv->getName () == TargetEnv)) {
698
698
if (Message) {
699
699
Message->clear ();
700
700
llvm::raw_string_ostream Out (*Message);
701
701
VersionTuple VTI (A->getIntroduced ());
702
- Out << " introduced in " << PrettyPlatformName << " " << VTI << " "
703
- << EnvName << HintMessage;
702
+ Out << " introduced in " << PrettyPlatformName << " " << VTI;
703
+ if (Triple.hasEnvironment ())
704
+ Out << " " << EnvName;
705
+ Out << HintMessage;
704
706
}
705
707
}
706
- // Non-matching environment or no environment on target
708
+ // Non-matching environment or no environment on target.
707
709
else {
708
710
if (Message) {
709
711
Message->clear ();
710
712
llvm::raw_string_ostream Out (*Message);
711
- Out << " not available on " << PrettyPlatformName << " " << EnvName
712
- << HintMessage;
713
+ Out << " not available on " << PrettyPlatformName;
714
+ if (Triple.hasEnvironment ())
715
+ Out << " " << EnvName;
716
+ Out << HintMessage;
713
717
}
714
718
}
715
719
0 commit comments