mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Merge pull request #38326 from etcwilde/ewilde/swift-rebranch
[Swift Rebranch] Cherry-picking swift changes from next branch
This commit is contained in:
@@ -78,6 +78,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>;
|
||||
@@ -5567,7 +5571,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");
|
||||
@@ -5588,7 +5592,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;
|
||||
@@ -5605,7 +5609,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;
|
||||
@@ -5627,12 +5631,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;
|
||||
}
|
||||
|
||||
@@ -5647,7 +5651,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) {
|
||||
@@ -5658,7 +5662,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) {
|
||||
|
||||
Reference in New Issue
Block a user