Skip to content

Commit 1ce17af

Browse files
committed
Merge commit 'a25d2803d7d9' from apple/stable/20210107 into swift/main
2 parents cc01031 + a25d280 commit 1ce17af

File tree

83 files changed

+1187
-817
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+1187
-817
lines changed

clang/lib/CodeGen/CGStmt.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1157,7 +1157,7 @@ static void makeTailCallIfSwiftAsync(const CallExpr *CE, CGBuilderTy &Builder,
11571157
&& (CurFnInfo->getASTCallingConvention() ==
11581158
CallingConv::CC_SwiftAsync)) {
11591159
auto CI = cast<llvm::CallInst>(&Builder.GetInsertBlock()->back());
1160-
CI->setTailCallKind(llvm::CallInst::TCK_Tail);
1160+
CI->setTailCallKind(llvm::CallInst::TCK_MustTail);
11611161
Builder.CreateRetVoid();
11621162
Builder.ClearInsertionPoint();
11631163
}

clang/lib/Driver/Driver.cpp

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,6 +1049,69 @@ Compilation *Driver::BuildCompilation(ArrayRef<const char *> ArgList) {
10491049
}
10501050
}
10511051

1052+
[&]() {
1053+
if (ContainsError)
1054+
return;
1055+
1056+
llvm::SmallVector<const char *, 16> WarningsToDisable = {
1057+
"-Wno-elaborated-enum-base",
1058+
};
1059+
1060+
llvm::SmallVector<const char *, 32> ExtraArgs = {
1061+
// Add other command-line arguments here.
1062+
};
1063+
1064+
// Append WarningsToDisable to ExtraArgs, although do not disable warnings
1065+
// the command-line has explicitly turned on.
1066+
//
1067+
// TODO: Consider handling warning groups specially.
1068+
if (!WarningsToDisable.empty()) {
1069+
// Map the warnings explicitly turned on by the command-line.
1070+
llvm::StringSet<> WarningsToKeep;
1071+
for (auto *Arg : Args) {
1072+
if (!Arg->getOption().matches(options::OPT_W_Joined))
1073+
continue;
1074+
StringRef Value = Arg->getValue();
1075+
if (Value.empty())
1076+
continue; // Skip past "-W"
1077+
1078+
// Handle "-Wflag", "-Werror=flag", and "-Wno-flag". Ignore
1079+
// "-Wno-error=flag" since it doesn't turn the warning on or off.
1080+
if (Value.consume_front("no-")) {
1081+
WarningsToKeep.erase(Value);
1082+
continue;
1083+
}
1084+
(void)Value.consume_front("error=");
1085+
WarningsToKeep.insert(Value);
1086+
}
1087+
1088+
// Disable any warnings not explicitly turned on.
1089+
for (const char *Warning : WarningsToDisable) {
1090+
StringRef S(Warning);
1091+
bool Consumed = S.consume_front("-Wno-");
1092+
(void)Consumed;
1093+
assert(Consumed && "Warning flag should be in '-Wno-' form");
1094+
if (!WarningsToKeep.count(S))
1095+
ExtraArgs.push_back(Warning);
1096+
}
1097+
}
1098+
1099+
if (ExtraArgs.empty())
1100+
return; // Nothing to do...
1101+
1102+
// Process the extra arguments, adding them to the main Args list.
1103+
InputArgList ExtraOptions =
1104+
ParseArgStrings(ExtraArgs, /*IsClCompatMode=*/false, ContainsError);
1105+
if (ContainsError)
1106+
return;
1107+
for (auto *Opt : ExtraOptions) {
1108+
// Always claim these implicit arguments to avoid strange warnings
1109+
// in -v output.
1110+
Opt->claim();
1111+
appendOneArg(Opt, nullptr);
1112+
}
1113+
}();
1114+
10521115
// Check for working directory option before accessing any files
10531116
if (Arg *WD = Args.getLastArg(options::OPT_working_directory))
10541117
if (VFS->setCurrentWorkingDirectory(WD->getValue()))

clang/lib/Driver/ToolChains/Darwin.cpp

Lines changed: 35 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1690,6 +1690,15 @@ getDeploymentTargetFromEnvironmentVariables(const Driver &TheDriver,
16901690
return None;
16911691
}
16921692

1693+
/// Returns the SDK name without the optional prefix that ends with a '.' or an
1694+
/// empty string otherwise.
1695+
static StringRef dropSDKNamePrefix(StringRef SDKName) {
1696+
size_t PrefixPos = SDKName.find('.');
1697+
if (PrefixPos == StringRef::npos)
1698+
return "";
1699+
return SDKName.substr(PrefixPos + 1);
1700+
}
1701+
16931702
/// Tries to infer the deployment target from the SDK specified by -isysroot
16941703
/// (or SDKROOT). Uses the version specified in the SDKSettings.json file if
16951704
/// it's available.
@@ -1719,22 +1728,29 @@ inferDeploymentTargetFromSDK(DerivedArgList &Args,
17191728
if (Version.empty())
17201729
return None;
17211730

1722-
if (SDK.startswith("iPhoneOS") || SDK.startswith("iPhoneSimulator"))
1723-
return DarwinPlatform::createFromSDK(
1724-
Darwin::IPhoneOS, Version,
1725-
/*IsSimulator=*/SDK.startswith("iPhoneSimulator"));
1726-
else if (SDK.startswith("MacOSX"))
1727-
return DarwinPlatform::createFromSDK(Darwin::MacOS,
1728-
getSystemOrSDKMacOSVersion(Version));
1729-
else if (SDK.startswith("WatchOS") || SDK.startswith("WatchSimulator"))
1730-
return DarwinPlatform::createFromSDK(
1731-
Darwin::WatchOS, Version,
1732-
/*IsSimulator=*/SDK.startswith("WatchSimulator"));
1733-
else if (SDK.startswith("AppleTVOS") || SDK.startswith("AppleTVSimulator"))
1734-
return DarwinPlatform::createFromSDK(
1735-
Darwin::TvOS, Version,
1736-
/*IsSimulator=*/SDK.startswith("AppleTVSimulator"));
1737-
return None;
1731+
auto CreatePlatformFromSDKName =
1732+
[&](StringRef SDK) -> Optional<DarwinPlatform> {
1733+
if (SDK.startswith("iPhoneOS") || SDK.startswith("iPhoneSimulator"))
1734+
return DarwinPlatform::createFromSDK(
1735+
Darwin::IPhoneOS, Version,
1736+
/*IsSimulator=*/SDK.startswith("iPhoneSimulator"));
1737+
else if (SDK.startswith("MacOSX"))
1738+
return DarwinPlatform::createFromSDK(Darwin::MacOS,
1739+
getSystemOrSDKMacOSVersion(Version));
1740+
else if (SDK.startswith("WatchOS") || SDK.startswith("WatchSimulator"))
1741+
return DarwinPlatform::createFromSDK(
1742+
Darwin::WatchOS, Version,
1743+
/*IsSimulator=*/SDK.startswith("WatchSimulator"));
1744+
else if (SDK.startswith("AppleTVOS") || SDK.startswith("AppleTVSimulator"))
1745+
return DarwinPlatform::createFromSDK(
1746+
Darwin::TvOS, Version,
1747+
/*IsSimulator=*/SDK.startswith("AppleTVSimulator"));
1748+
return None;
1749+
};
1750+
if (auto Result = CreatePlatformFromSDKName(SDK))
1751+
return Result;
1752+
// The SDK can be an SDK variant with a name like `<prefix>.<platform>`.
1753+
return CreatePlatformFromSDKName(dropSDKNamePrefix(SDK));
17381754
}
17391755

17401756
std::string getOSVersion(llvm::Triple::OSType OS, const llvm::Triple &Triple,
@@ -2000,7 +2016,9 @@ void Darwin::AddDeploymentTarget(DerivedArgList &Args) const {
20002016
StringRef SDKName = SDK.slice(0, StartVer);
20012017
// Don't warn about the macabi SDK.
20022018
// FIXME: Can we warn here?
2003-
if (!SDKName.startswith(getPlatformFamily()) && Environment != MacABI)
2019+
if (!SDKName.startswith(getPlatformFamily()) &&
2020+
!dropSDKNamePrefix(SDKName).startswith(getPlatformFamily())
2021+
&& Environment != MacABI)
20042022
getDriver().Diag(diag::warn_incompatible_sysroot)
20052023
<< SDKName << getPlatformFamily();
20062024
}

clang/lib/Sema/SemaDeclAttr.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,8 @@ static bool isInstanceMethod(const Decl *D) {
153153
return false;
154154
}
155155

156-
static inline bool isNSStringType(QualType T, ASTContext &Ctx) {
156+
static inline bool isNSStringType(QualType T, ASTContext &Ctx,
157+
bool AllowNSAttributedString = false) {
157158
const auto *PT = T->getAs<ObjCObjectPointerType>();
158159
if (!PT)
159160
return false;
@@ -164,6 +165,9 @@ static inline bool isNSStringType(QualType T, ASTContext &Ctx) {
164165

165166
IdentifierInfo* ClsName = Cls->getIdentifier();
166167

168+
if (AllowNSAttributedString &&
169+
ClsName == &Ctx.Idents.get("NSAttributedString"))
170+
return true;
167171
// FIXME: Should we walk the chain of classes?
168172
return ClsName == &Ctx.Idents.get("NSString") ||
169173
ClsName == &Ctx.Idents.get("NSMutableString");
@@ -3337,7 +3341,7 @@ static void handleFormatArgAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
33373341
return;
33383342
}
33393343
Ty = getFunctionOrMethodResultType(D);
3340-
if (!isNSStringType(Ty, S.Context) &&
3344+
if (!isNSStringType(Ty, S.Context, /*AllowNSAttributedString=*/true) &&
33413345
!isCFStringType(Ty, S.Context) &&
33423346
(!Ty->isPointerType() ||
33433347
!Ty->castAs<PointerType>()->getPointeeType()->isCharType())) {

clang/test/CodeGen/swift-async-call-conv.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ SWIFTASYNCCALL void async_leaf2(char * ASYNC_CONTEXT ctx) {
3434
#endif
3535

3636
// CHECK-LABEL: swifttailcc void {{.*}}async_branch{{.*}}i8* swiftasync
37-
// CHECK: tail call swifttailcc void @{{.*}}async_leaf1
37+
// CHECK: musttail call swifttailcc void @{{.*}}async_leaf1
3838
// CHECK-NEXT: ret void
39-
// CHECK: tail call swifttailcc void @{{.*}}async_leaf2
39+
// CHECK: musttail call swifttailcc void @{{.*}}async_leaf2
4040
// CHECK-NEXT: ret void
4141
SWIFTASYNCCALL void async_branch(MYBOOL b, char * ASYNC_CONTEXT ctx) {
4242
if (b) {
@@ -47,22 +47,22 @@ SWIFTASYNCCALL void async_branch(MYBOOL b, char * ASYNC_CONTEXT ctx) {
4747
}
4848

4949
// CHECK-LABEL: swifttailcc void {{.*}}async_not_all_tail
50-
// CHECK-NOT: tail call swifttailcc void @{{.*}}async_leaf1
50+
// CHECK-NOT: musttail call swifttailcc void @{{.*}}async_leaf1
5151
// CHECK: call swifttailcc void @{{.*}}async_leaf1
5252
// CHECK-NOT: ret void
53-
// CHECK: tail call swifttailcc void @{{.*}}async_leaf2
53+
// CHECK: musttail call swifttailcc void @{{.*}}async_leaf2
5454
// CHECK-NEXT: ret void
5555
SWIFTASYNCCALL void async_not_all_tail(char * ASYNC_CONTEXT ctx) {
5656
async_leaf1(ctx);
5757
return async_leaf2(ctx);
5858
}
5959

6060
// CHECK-LABEL: swifttailcc void {{.*}}async_loop
61-
// CHECK: tail call swifttailcc void @{{.*}}async_leaf1
61+
// CHECK: musttail call swifttailcc void @{{.*}}async_leaf1
6262
// CHECK-NEXT: ret void
63-
// CHECK: tail call swifttailcc void @{{.*}}async_leaf2
63+
// CHECK: musttail call swifttailcc void @{{.*}}async_leaf2
6464
// CHECK-NEXT: ret void
65-
// CHECK: tail call swifttailcc void @{{.*}}async_loop
65+
// CHECK: musttail call swifttailcc void @{{.*}}async_loop
6666
// CHECK-NEXT: ret void
6767
SWIFTASYNCCALL void async_loop(unsigned u, char * ASYNC_CONTEXT ctx) {
6868
if (u == 0) {
@@ -78,9 +78,9 @@ SWIFTASYNCCALL void async_loop(unsigned u, char * ASYNC_CONTEXT ctx) {
7878
SWIFTASYNCCALL void async_mutual_loop2(unsigned u, char * ASYNC_CONTEXT ctx);
7979

8080
// CHECK-LABEL: swifttailcc void {{.*}}async_mutual_loop1
81-
// CHECK: tail call swifttailcc void @{{.*}}async_leaf1
81+
// CHECK: musttail call swifttailcc void @{{.*}}async_leaf1
8282
// CHECK-NEXT: ret void
83-
// CHECK: tail call swifttailcc void @{{.*}}async_leaf2
83+
// CHECK: musttail call swifttailcc void @{{.*}}async_leaf2
8484
// CHECK-NEXT: ret void
8585
// There is some bugginess around FileCheck's greediness/matching,
8686
// so skipping the check for async_mutual_loop2 here.
@@ -94,11 +94,11 @@ SWIFTASYNCCALL void async_mutual_loop1(unsigned u, char * ASYNC_CONTEXT ctx) {
9494
}
9595

9696
// CHECK-LABEL: swifttailcc void {{.*}}async_mutual_loop2
97-
// CHECK: tail call swifttailcc void @{{.*}}async_leaf1
97+
// CHECK: musttail call swifttailcc void @{{.*}}async_leaf1
9898
// CHECK-NEXT: ret void
99-
// CHECK: tail call swifttailcc void @{{.*}}async_leaf2
99+
// CHECK: musttail call swifttailcc void @{{.*}}async_leaf2
100100
// CHECK-NEXT: ret void
101-
// CHECK: tail call swifttailcc void @{{.*}}async_mutual_loop1
101+
// CHECK: musttail call swifttailcc void @{{.*}}async_mutual_loop1
102102
// CHECK-NEXT: ret void
103103
SWIFTASYNCCALL void async_mutual_loop2(unsigned u, char * ASYNC_CONTEXT ctx) {
104104
if (u == 0) {
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// RUN: rm -rf %t.dir
2+
// RUN: mkdir -p %t.dir
3+
4+
// RUN: rm -rf %t.dir/prefix.iPhoneOS12.0.0.sdk
5+
// RUN: mkdir -p %t.dir/prefix.iPhoneOS12.0.0.sdk
6+
// RUN: %clang -c -isysroot %t.dir/prefix.iPhoneOS12.0.0.sdk -target arm64-apple-darwin %s -### 2>&1 | FileCheck %s
7+
// RUN: env SDKROOT=%t.dir/prefix.iPhoneOS12.0.0.sdk %clang -c -target arm64-apple-darwin %s -### 2>&1 | FileCheck %s
8+
//
9+
// CHECK-NOT: warning: using sysroot for
10+
// CHECK: "-triple" "arm64-apple-ios12.0.0"

clang/test/Driver/myriad-toolchain.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262

6363
// RUN: %clang -target shave-myriad -c %s -o foo.o -### -MD -MF dep.d 2>&1 \
6464
// RUN: | FileCheck %s -check-prefix=MDMF
65-
// MDMF: "-S" "-fno-exceptions" "-DMYRIAD2" "-MD" "-MF" "dep.d" "-MT" "foo.o"
65+
// MDMF: "-S" "-fno-exceptions" "-DMYRIAD2" "-MD" "-MF" "dep.d" "-Wno-elaborated-enum-base" "-MT" "foo.o"
6666

6767
// RUN: %clang -target shave-myriad -std=gnu++11 -mcpu=anothercpu -S %s -o foo.o -### 2>&1 \
6868
// RUN: | FileCheck %s -check-prefix=STDEQ

clang/test/Driver/workarounds.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// Check that Driver workarounds are enabled.
2+
//
3+
// RUN: %clang %s -### 2>&1 | FileCheck %s
4+
// RUN: %clang -target x86_64-apple-darwin %s -### 2>&1 | FileCheck %s
5+
// RUN: %clang -target x86_64-linux-unknown %s -### 2>&1 | FileCheck %s
6+
// RUN: %clang -target x86_64-apple-darwin %s -W -### 2>&1 | FileCheck %s
7+
// CHECK: "-cc1"
8+
// Note: Add CHECK-SAME checks after this note for each workaround.
9+
// CHECK-SAME: "-Wno-elaborated-enum-base"
10+

clang/test/SemaObjC/format-arg-attribute.m

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// RUN: %clang_cc1 -verify -fsyntax-only %s
22

33
@class NSString;
4+
@class NSAttributedString;
45

56
extern NSString *fa2 (const NSString *) __attribute__((format_arg(1)));
67
extern NSString *fa3 (NSString *) __attribute__((format_arg(1)));
@@ -25,3 +26,5 @@
2526
extern int fi3 (const NSString *) __attribute__((format_arg(1))); // expected-error {{function does not return NSString}}
2627
extern NSString *fi4 (const NSString *) __attribute__((format_arg(1)));
2728
extern NSString *fi5 (const NSString *) __attribute__((format_arg(1)));
29+
30+
extern NSAttributedString *fattrs (const NSString *) __attribute__((format_arg(1)));

compiler-rt/lib/ubsan/ubsan_diag.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,10 @@ ScopedReport::ScopedReport(ReportOptions Opts, Location SummaryLoc,
388388
ScopedReport::~ScopedReport() {
389389
MaybePrintStackTrace(Opts.pc, Opts.bp);
390390
MaybeReportErrorSummary(SummaryLoc, Type);
391+
392+
if (common_flags()->print_module_map >= 2)
393+
DumpProcessMap();
394+
391395
if (flags()->halt_on_error)
392396
Die();
393397
}

compiler-rt/lib/ubsan/ubsan_init.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ static void CommonInit() {
3333
InitializeSuppressions();
3434
}
3535

36+
static void UbsanDie() {
37+
if (common_flags()->print_module_map >= 1)
38+
DumpProcessMap();
39+
}
40+
3641
static void CommonStandaloneInit() {
3742
SanitizerToolName = GetSanititizerToolName();
3843
CacheBinaryName();
@@ -42,6 +47,10 @@ static void CommonStandaloneInit() {
4247
AndroidLogInit();
4348
InitializeCoverage(common_flags()->coverage, common_flags()->coverage_dir);
4449
CommonInit();
50+
51+
// Only add die callback when running in standalone mode to avoid printing
52+
// the same information from multiple sanitizers' output
53+
AddDieCallback(UbsanDie);
4554
Symbolizer::LateInitialize();
4655
}
4756

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// Checks that module map does not print at 0, prints once after aborting with 1,
2+
// and prints once before and after aborting with 2
3+
4+
// RUN: %clangxx -DUSING_%tool_name %s -o %t -w
5+
6+
// RUN: %env_tool_opts="print_module_map=0" not %run %t 2>&1 | FileCheck %s --check-prefixes=CHECK,CHECK-MM0
7+
// RUN: %env_tool_opts="print_module_map=1" not %run %t 2>&1 | FileCheck %s --check-prefixes=CHECK,CHECK-MM1
8+
// RUN: %env_tool_opts="print_module_map=2" not %run %t 2>&1 | FileCheck %s --check-prefixes=CHECK,CHECK-MM2
9+
10+
// tsan support pending rdar://67747473
11+
// XFAIL: tsan
12+
13+
// FIXME: Add linux support.
14+
// XFAIL: msan && linux
15+
16+
// FIXME: Add lsan support.
17+
// XFAIL: lsan
18+
19+
int global;
20+
21+
int main() {
22+
#if defined(USING_ubsan)
23+
int value = 5;
24+
int computation = value / 0; // Division by zero.
25+
#else
26+
volatile int *a = new int[100];
27+
delete[] a;
28+
global = a[0]; // use-after-free: triggers ASan/TSan report.
29+
#endif
30+
return 0;
31+
}
32+
33+
// CHECK: SUMMARY:
34+
// CHECK-MM0-NOT: Process module map:
35+
// CHECK-MM1-NOT: Process module map:
36+
// CHECK-MM2: Process module map:
37+
// CHECK: ABORTING
38+
// CHECK-MM0-NOT: Process module map:
39+
// CHECK-MM1-NEXT: Process module map:
40+
// CHECK-MM2-NEXT: Process module map:

lldb/bindings/interface/SBAddress.i

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ libraries, bundles, frameworks) being loaded at different
1717
addresses than the addresses found in the object file that
1818
represents them on disk. There are currently two types of addresses
1919
for a section:
20-
o file addresses
21-
o load addresses
20+
21+
* file addresses
22+
* load addresses
2223
2324
File addresses represents the virtual addresses that are in the 'on
2425
disk' object files. These virtual addresses are converted to be

0 commit comments

Comments
 (0)