@@ -78,6 +78,10 @@ using llvm::BCBlockRAII;
78
78
79
79
ASTContext &SerializerBase::getASTContext () const { return M->getASTContext (); }
80
80
81
+ static StringRef withNullAsEmptyStringRef (const char *data) {
82
+ return StringRef (data ? data : " " );
83
+ }
84
+
81
85
// / Used for static_assert.
82
86
static constexpr bool declIDFitsIn32Bits () {
83
87
using Int32Info = std::numeric_limits<uint32_t >;
@@ -5554,7 +5558,7 @@ void swift::serializeToBuffers(
5554
5558
std::unique_ptr<llvm::MemoryBuffer> *moduleSourceInfoBuffer,
5555
5559
const SILModule *M) {
5556
5560
5557
- assert (!StringRef::withNullAsEmpty (options.OutputPath ).empty ());
5561
+ assert (!withNullAsEmptyStringRef (options.OutputPath ).empty ());
5558
5562
{
5559
5563
FrontendStatsTracer tracer (getContext (DC).Stats ,
5560
5564
" Serialization, swiftmodule, to buffer" );
@@ -5575,7 +5579,7 @@ void swift::serializeToBuffers(
5575
5579
std::move (buf), options.OutputPath );
5576
5580
}
5577
5581
5578
- if (!StringRef::withNullAsEmpty (options.DocOutputPath ).empty ()) {
5582
+ if (!withNullAsEmptyStringRef (options.DocOutputPath ).empty ()) {
5579
5583
FrontendStatsTracer tracer (getContext (DC).Stats ,
5580
5584
" Serialization, swiftdoc, to buffer" );
5581
5585
llvm::SmallString<1024 > buf;
@@ -5592,7 +5596,7 @@ void swift::serializeToBuffers(
5592
5596
std::move (buf), options.DocOutputPath );
5593
5597
}
5594
5598
5595
- if (!StringRef::withNullAsEmpty (options.SourceInfoOutputPath ).empty ()) {
5599
+ if (!withNullAsEmptyStringRef (options.SourceInfoOutputPath ).empty ()) {
5596
5600
FrontendStatsTracer tracer (getContext (DC).Stats ,
5597
5601
" Serialization, swiftsourceinfo, to buffer" );
5598
5602
llvm::SmallString<1024 > buf;
@@ -5614,12 +5618,12 @@ void swift::serialize(ModuleOrSourceFile DC,
5614
5618
const SerializationOptions &options,
5615
5619
const SILModule *M,
5616
5620
const fine_grained_dependencies::SourceFileDepGraph *DG) {
5617
- assert (!StringRef::withNullAsEmpty (options.OutputPath ).empty ());
5621
+ assert (!withNullAsEmptyStringRef (options.OutputPath ).empty ());
5618
5622
5619
5623
if (StringRef (options.OutputPath ) == " -" ) {
5620
5624
// Special-case writing to stdout.
5621
5625
Serializer::writeToStream (llvm::outs (), DC, M, options, DG);
5622
- assert (StringRef::withNullAsEmpty (options.DocOutputPath ).empty ());
5626
+ assert (withNullAsEmptyStringRef (options.DocOutputPath ).empty ());
5623
5627
return ;
5624
5628
}
5625
5629
@@ -5634,7 +5638,7 @@ void swift::serialize(ModuleOrSourceFile DC,
5634
5638
if (hadError)
5635
5639
return ;
5636
5640
5637
- if (!StringRef::withNullAsEmpty (options.DocOutputPath ).empty ()) {
5641
+ if (!withNullAsEmptyStringRef (options.DocOutputPath ).empty ()) {
5638
5642
(void )withOutputFile (getContext (DC).Diags ,
5639
5643
options.DocOutputPath ,
5640
5644
[&](raw_ostream &out) {
@@ -5645,7 +5649,7 @@ void swift::serialize(ModuleOrSourceFile DC,
5645
5649
});
5646
5650
}
5647
5651
5648
- if (!StringRef::withNullAsEmpty (options.SourceInfoOutputPath ).empty ()) {
5652
+ if (!withNullAsEmptyStringRef (options.SourceInfoOutputPath ).empty ()) {
5649
5653
(void )withOutputFile (getContext (DC).Diags ,
5650
5654
options.SourceInfoOutputPath ,
5651
5655
[&](raw_ostream &out) {
0 commit comments