Skip to content

Commit 9ee9dd6

Browse files
committed
Address review comments
1 parent d642c83 commit 9ee9dd6

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

clang/lib/AST/DeclBase.cpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -698,26 +698,28 @@ static AvailabilityResult CheckAvailability(ASTContext &Context,
698698
auto &Triple = Context.getTargetInfo().getTriple();
699699
StringRef TargetEnv = Triple.getEnvironmentName();
700700
StringRef EnvName =
701-
Triple.hasEnvironment()
702-
? llvm::Triple::getEnvironmentTypeName(Triple.getEnvironment())
703-
: "";
701+
llvm::Triple::getEnvironmentTypeName(Triple.getEnvironment());
704702
// Matching environment or no environment on attribute.
705-
if (!IIEnv || (!TargetEnv.empty() && IIEnv->getName() == TargetEnv)) {
703+
if (!IIEnv || (Triple.hasEnvironment() && IIEnv->getName() == TargetEnv)) {
706704
if (Message) {
707705
Message->clear();
708706
llvm::raw_string_ostream Out(*Message);
709707
VersionTuple VTI(A->getIntroduced());
710-
Out << "introduced in " << PrettyPlatformName << " " << VTI << " "
711-
<< EnvName << HintMessage;
708+
Out << "introduced in " << PrettyPlatformName << " " << VTI;
709+
if (Triple.hasEnvironment())
710+
Out << " " << EnvName;
711+
Out << HintMessage;
712712
}
713713
}
714714
// Non-matching environment or no environment on target.
715715
else {
716716
if (Message) {
717717
Message->clear();
718718
llvm::raw_string_ostream Out(*Message);
719-
Out << "not available on " << PrettyPlatformName << " " << EnvName
720-
<< HintMessage;
719+
Out << "not available on " << PrettyPlatformName;
720+
if (Triple.hasEnvironment())
721+
Out << " " << EnvName;
722+
Out << HintMessage;
721723
}
722724
}
723725

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// RUN: not %clang -target x86_64-apple-darwin9 -fsyntax-only %s 2>&1 | FileCheck %s
2+
3+
// CHECK: error:
4+
// CHECK-SAME: 'f0' is unavailable: introduced in macOS 11
5+
// CHECK-NOT: unknown
6+
7+
void f0(void) __attribute__((availability(macosx,strict,introduced=11)));
8+
9+
void client(void) {
10+
f0(); }

0 commit comments

Comments
 (0)