@@ -689,27 +689,31 @@ static AvailabilityResult CheckAvailability(ASTContext &Context,
689689 if (!A->getIntroduced ().empty () &&
690690 EnclosingVersion < A->getIntroduced ()) {
691691 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)) {
698698 if (Message) {
699699 Message->clear ();
700700 llvm::raw_string_ostream Out (*Message);
701701 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;
704706 }
705707 }
706- // Non-matching environment or no environment on target
708+ // Non-matching environment or no environment on target.
707709 else {
708710 if (Message) {
709711 Message->clear ();
710712 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;
713717 }
714718 }
715719
0 commit comments