Merge pull request #39473 from apple/rebranch

Update swift:main to support llvm-project:stable/20210726 changes (Rebranch merge)
This commit is contained in:
Mishal Shah
2021-10-11 09:00:51 -07:00
committed by GitHub
183 changed files with 1039 additions and 648 deletions

View File

@@ -80,6 +80,10 @@ using llvm::BCBlockRAII;
ASTContext &SerializerBase::getASTContext() const { return M->getASTContext(); }
static StringRef withNullAsEmptyStringRef(const char *data) {
return StringRef(data ? data : "");
}
/// Used for static_assert.
static constexpr bool declIDFitsIn32Bits() {
using Int32Info = std::numeric_limits<uint32_t>;
@@ -5675,7 +5679,7 @@ void swift::serializeToBuffers(
std::unique_ptr<llvm::MemoryBuffer> *moduleSourceInfoBuffer,
const SILModule *M) {
assert(!StringRef::withNullAsEmpty(options.OutputPath).empty());
assert(!withNullAsEmptyStringRef(options.OutputPath).empty());
{
FrontendStatsTracer tracer(getContext(DC).Stats,
"Serialization, swiftmodule, to buffer");
@@ -5697,7 +5701,7 @@ void swift::serializeToBuffers(
std::move(buf), options.OutputPath);
}
if (!StringRef::withNullAsEmpty(options.DocOutputPath).empty()) {
if (!withNullAsEmptyStringRef(options.DocOutputPath).empty()) {
FrontendStatsTracer tracer(getContext(DC).Stats,
"Serialization, swiftdoc, to buffer");
llvm::SmallString<1024> buf;
@@ -5714,7 +5718,7 @@ void swift::serializeToBuffers(
std::move(buf), options.DocOutputPath);
}
if (!StringRef::withNullAsEmpty(options.SourceInfoOutputPath).empty()) {
if (!withNullAsEmptyStringRef(options.SourceInfoOutputPath).empty()) {
FrontendStatsTracer tracer(getContext(DC).Stats,
"Serialization, swiftsourceinfo, to buffer");
llvm::SmallString<1024> buf;
@@ -5736,12 +5740,12 @@ void swift::serialize(ModuleOrSourceFile DC,
const SerializationOptions &options,
const SILModule *M,
const fine_grained_dependencies::SourceFileDepGraph *DG) {
assert(!StringRef::withNullAsEmpty(options.OutputPath).empty());
assert(!withNullAsEmptyStringRef(options.OutputPath).empty());
if (StringRef(options.OutputPath) == "-") {
// Special-case writing to stdout.
Serializer::writeToStream(llvm::outs(), DC, M, options, DG);
assert(StringRef::withNullAsEmpty(options.DocOutputPath).empty());
assert(withNullAsEmptyStringRef(options.DocOutputPath).empty());
return;
}
@@ -5756,7 +5760,7 @@ void swift::serialize(ModuleOrSourceFile DC,
if (hadError)
return;
if (!StringRef::withNullAsEmpty(options.DocOutputPath).empty()) {
if (!withNullAsEmptyStringRef(options.DocOutputPath).empty()) {
(void)withOutputFile(getContext(DC).Diags,
options.DocOutputPath,
[&](raw_ostream &out) {
@@ -5767,7 +5771,7 @@ void swift::serialize(ModuleOrSourceFile DC,
});
}
if (!StringRef::withNullAsEmpty(options.SourceInfoOutputPath).empty()) {
if (!withNullAsEmptyStringRef(options.SourceInfoOutputPath).empty()) {
(void)withOutputFile(getContext(DC).Diags,
options.SourceInfoOutputPath,
[&](raw_ostream &out) {