Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 15 additions & 11 deletions clang/lib/AST/DeclBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -689,27 +689,31 @@ static AvailabilityResult CheckAvailability(ASTContext &Context,
if (!A->getIntroduced().empty() &&
EnclosingVersion < A->getIntroduced()) {
IdentifierInfo *IIEnv = A->getEnvironment();
StringRef TargetEnv =
Context.getTargetInfo().getTriple().getEnvironmentName();
StringRef EnvName = llvm::Triple::getEnvironmentTypeName(
Context.getTargetInfo().getTriple().getEnvironment());
// Matching environment or no environment on attribute
if (!IIEnv || (!TargetEnv.empty() && IIEnv->getName() == TargetEnv)) {
auto &Triple = Context.getTargetInfo().getTriple();
StringRef TargetEnv = Triple.getEnvironmentName();
StringRef EnvName =
llvm::Triple::getEnvironmentTypeName(Triple.getEnvironment());
// Matching environment or no environment on attribute.
if (!IIEnv || (Triple.hasEnvironment() && IIEnv->getName() == TargetEnv)) {
if (Message) {
Message->clear();
llvm::raw_string_ostream Out(*Message);
VersionTuple VTI(A->getIntroduced());
Out << "introduced in " << PrettyPlatformName << " " << VTI << " "
<< EnvName << HintMessage;
Out << "introduced in " << PrettyPlatformName << " " << VTI;
if (Triple.hasEnvironment())
Out << " " << EnvName;
Out << HintMessage;
}
}
// Non-matching environment or no environment on target
// Non-matching environment or no environment on target.
else {
if (Message) {
Message->clear();
llvm::raw_string_ostream Out(*Message);
Out << "not available on " << PrettyPlatformName << " " << EnvName
<< HintMessage;
Out << "not available on " << PrettyPlatformName;
if (Triple.hasEnvironment())
Out << " " << EnvName;
Out << HintMessage;
}
}

Expand Down
4 changes: 3 additions & 1 deletion clang/lib/Serialization/ModuleManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,9 @@ ModuleManager::addModule(StringRef FileName, ModuleKind Type,
// Note: ExpectedSize and ExpectedModTime will be 0 for MK_ImplicitModule
// when using an ASTFileSignature.
if (lookupModuleFile(FileName, ExpectedSize, ExpectedModTime, Entry)) {
ErrorStr = "module file out of date";
ErrorStr = IgnoreModTime
? "module file has a different size than expected"
: "module file has a different size or mtime than expected";
return OutOfDate;
}

Expand Down
10 changes: 10 additions & 0 deletions clang/test/Driver/attr-availability-erroneous-diags.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// RUN: not %clang -target x86_64-apple-darwin9 -fsyntax-only %s 2>&1 | FileCheck %s

// CHECK: error:
// CHECK-SAME: 'f0' is unavailable: introduced in macOS 11
// CHECK-NOT: unknown

void f0(void) __attribute__((availability(macosx,strict,introduced=11)));

void client(void) {
f0(); }
4 changes: 2 additions & 2 deletions clang/test/Driver/xros-driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
// LINK: "-platform_version" "xros" "1.0.0" "1.0.0"
// LINK-SIM: "-platform_version" "xros-simulator" "1.0.0" "1.0.0"

// OBJC-RUNTIME: "-fobjc-runtime=ios-17.0.0.0"
// OBJC-RUNTIME2: "-fobjc-runtime=ios-18.0.0.0"
// OBJC-RUNTIME: "-fobjc-runtime=ios-17.0.0"
// OBJC-RUNTIME2: "-fobjc-runtime=ios-18.0.0"
// ARC-NOT: error:

// SSP_ON: "-stack-protector" "1"
Expand Down
2 changes: 1 addition & 1 deletion clang/test/Modules/explicit-build.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,6 @@
// RUN: -fmodule-file=%t/c.pcm \
// RUN: %s -DHAVE_A -DHAVE_B -DHAVE_C 2>&1 | FileCheck --check-prefix=CHECK-MISMATCHED-B %s
//
// CHECK-MISMATCHED-B: fatal error: module file '{{.*}}b.pcm' is out of date and needs to be rebuilt: module file out of date
// CHECK-MISMATCHED-B: fatal error: module file '{{.*}}b.pcm' is out of date and needs to be rebuilt: module file has a different size than expected
// CHECK-MISMATCHED-B-NEXT: note: imported by module 'c'
// CHECK-MISMATCHED-B-NOT: note:
4 changes: 1 addition & 3 deletions llvm/include/llvm/Support/VersionTuple.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,7 @@ class VersionTuple {

/// Return a version tuple that contains a different major version but
/// everything else is the same.
VersionTuple withMajorReplaced(unsigned NewMajor) const {
return VersionTuple(NewMajor, Minor, Subminor, Build);
}
VersionTuple withMajorReplaced(unsigned NewMajor) const;

/// Return a version tuple that contains only components that are non-zero.
VersionTuple normalize() const {
Expand Down
10 changes: 10 additions & 0 deletions llvm/lib/Support/VersionTuple.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,13 @@ bool VersionTuple::tryParse(StringRef input) {
*this = VersionTuple(major, minor, micro, build);
return false;
}

VersionTuple VersionTuple::withMajorReplaced(unsigned NewMajor) const {
if (HasBuild)
return VersionTuple(NewMajor, Minor, Subminor, Build);
if (HasSubminor)
return VersionTuple(NewMajor, Minor, Subminor);
if (HasMinor)
return VersionTuple(NewMajor, Minor);
return VersionTuple(NewMajor);
}
30 changes: 30 additions & 0 deletions llvm/unittests/Support/VersionTupleTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,33 @@ TEST(VersionTuple, tryParse) {
EXPECT_TRUE(VT.tryParse("1 "));
EXPECT_TRUE(VT.tryParse("."));
}

TEST(VersionTuple, withMajorReplaced) {
VersionTuple VT(2);
VersionTuple ReplacedVersion = VT.withMajorReplaced(7);
EXPECT_FALSE(ReplacedVersion.getMinor().has_value());
EXPECT_FALSE(ReplacedVersion.getSubminor().has_value());
EXPECT_FALSE(ReplacedVersion.getBuild().has_value());
EXPECT_EQ(VersionTuple(7), ReplacedVersion);

VT = VersionTuple(100, 1);
ReplacedVersion = VT.withMajorReplaced(7);
EXPECT_TRUE(ReplacedVersion.getMinor().has_value());
EXPECT_FALSE(ReplacedVersion.getSubminor().has_value());
EXPECT_FALSE(ReplacedVersion.getBuild().has_value());
EXPECT_EQ(VersionTuple(7, 1), ReplacedVersion);

VT = VersionTuple(101, 11, 12);
ReplacedVersion = VT.withMajorReplaced(7);
EXPECT_TRUE(ReplacedVersion.getMinor().has_value());
EXPECT_TRUE(ReplacedVersion.getSubminor().has_value());
EXPECT_FALSE(ReplacedVersion.getBuild().has_value());
EXPECT_EQ(VersionTuple(7, 11, 12), ReplacedVersion);

VT = VersionTuple(101, 11, 12, 2);
ReplacedVersion = VT.withMajorReplaced(7);
EXPECT_TRUE(ReplacedVersion.getMinor().has_value());
EXPECT_TRUE(ReplacedVersion.getSubminor().has_value());
EXPECT_TRUE(ReplacedVersion.getBuild().has_value());
EXPECT_EQ(VersionTuple(7, 11, 12, 2), ReplacedVersion);
}