mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[next] Convert const char * fields to StringRef
llvm/llvm-project d0262c2394f46bb7da2a75529413d625c70908e5 added a new default bool param to the two constructors in `SmallVectorMemoryBuffer`. Since `options.OutputPath` is a `const char *` and that can be promoted to a `bool`, the constructor being called was changed to the first constructor (with a default buffer name) - promotion is preferred over conversion. Convert the various output paths to a `StringRef` - all their uses converted to `StringRef` anyway. Also specify the default parameter in order to maintain the old behaviour, which didn't require a null terminator.
This commit is contained in:
@@ -5892,7 +5892,7 @@ void swift::serializeToBuffers(
|
||||
std::unique_ptr<llvm::MemoryBuffer> *moduleSourceInfoBuffer,
|
||||
const SILModule *M) {
|
||||
|
||||
assert(!withNullAsEmptyStringRef(options.OutputPath).empty());
|
||||
assert(!options.OutputPath.empty());
|
||||
{
|
||||
FrontendStatsTracer tracer(getContext(DC).Stats,
|
||||
"Serialization, swiftmodule, to buffer");
|
||||
@@ -5911,10 +5911,11 @@ void swift::serializeToBuffers(
|
||||
emitABIDescriptor(DC, options);
|
||||
if (moduleBuffer)
|
||||
*moduleBuffer = std::make_unique<llvm::SmallVectorMemoryBuffer>(
|
||||
std::move(buf), options.OutputPath);
|
||||
std::move(buf), options.OutputPath,
|
||||
/*RequiresNullTerminator=*/false);
|
||||
}
|
||||
|
||||
if (!withNullAsEmptyStringRef(options.DocOutputPath).empty()) {
|
||||
if (!options.DocOutputPath.empty()) {
|
||||
FrontendStatsTracer tracer(getContext(DC).Stats,
|
||||
"Serialization, swiftdoc, to buffer");
|
||||
llvm::SmallString<1024> buf;
|
||||
@@ -5928,10 +5929,11 @@ void swift::serializeToBuffers(
|
||||
});
|
||||
if (moduleDocBuffer)
|
||||
*moduleDocBuffer = std::make_unique<llvm::SmallVectorMemoryBuffer>(
|
||||
std::move(buf), options.DocOutputPath);
|
||||
std::move(buf), options.DocOutputPath,
|
||||
/*RequiresNullTerminator=*/false);
|
||||
}
|
||||
|
||||
if (!withNullAsEmptyStringRef(options.SourceInfoOutputPath).empty()) {
|
||||
if (!options.SourceInfoOutputPath.empty()) {
|
||||
FrontendStatsTracer tracer(getContext(DC).Stats,
|
||||
"Serialization, swiftsourceinfo, to buffer");
|
||||
llvm::SmallString<1024> buf;
|
||||
@@ -5945,7 +5947,8 @@ void swift::serializeToBuffers(
|
||||
});
|
||||
if (moduleSourceInfoBuffer)
|
||||
*moduleSourceInfoBuffer = std::make_unique<llvm::SmallVectorMemoryBuffer>(
|
||||
std::move(buf), options.SourceInfoOutputPath);
|
||||
std::move(buf), options.SourceInfoOutputPath,
|
||||
/*RequiresNullTerminator=*/false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5954,12 +5957,12 @@ void swift::serialize(ModuleOrSourceFile DC,
|
||||
const symbolgraphgen::SymbolGraphOptions &symbolGraphOptions,
|
||||
const SILModule *M,
|
||||
const fine_grained_dependencies::SourceFileDepGraph *DG) {
|
||||
assert(!withNullAsEmptyStringRef(options.OutputPath).empty());
|
||||
assert(!options.OutputPath.empty());
|
||||
|
||||
if (StringRef(options.OutputPath) == "-") {
|
||||
if (options.OutputPath == "-") {
|
||||
// Special-case writing to stdout.
|
||||
Serializer::writeToStream(llvm::outs(), DC, M, options, DG);
|
||||
assert(withNullAsEmptyStringRef(options.DocOutputPath).empty());
|
||||
assert(options.DocOutputPath.empty());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -5974,7 +5977,7 @@ void swift::serialize(ModuleOrSourceFile DC,
|
||||
if (hadError)
|
||||
return;
|
||||
|
||||
if (!withNullAsEmptyStringRef(options.DocOutputPath).empty()) {
|
||||
if (!options.DocOutputPath.empty()) {
|
||||
(void)withOutputFile(getContext(DC).Diags,
|
||||
options.DocOutputPath,
|
||||
[&](raw_ostream &out) {
|
||||
@@ -5985,7 +5988,7 @@ void swift::serialize(ModuleOrSourceFile DC,
|
||||
});
|
||||
}
|
||||
|
||||
if (!withNullAsEmptyStringRef(options.SourceInfoOutputPath).empty()) {
|
||||
if (!options.SourceInfoOutputPath.empty()) {
|
||||
(void)withOutputFile(getContext(DC).Diags,
|
||||
options.SourceInfoOutputPath,
|
||||
[&](raw_ostream &out) {
|
||||
|
||||
Reference in New Issue
Block a user