Skip to content

Commit 345a914

Browse files
committed
Explicit SmallString->std::string conversion.
This is only needed temporarily until commit d704921 from upstream LLVM hits the swift/master branch.
1 parent 32d2b14 commit 345a914

File tree

16 files changed

+34
-34
lines changed

16 files changed

+34
-34
lines changed

lib/AST/ASTPrinter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ std::string ASTPrinter::sanitizeUtf8(StringRef Text) {
272272
}
273273
Data += Step;
274274
}
275-
return std::string(Builder);
275+
return std::string(Builder.str());
276276
}
277277

278278
void ASTPrinter::anchor() {}

lib/AST/USRGeneration.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ swift::USRGenerationRequest::evaluate(Evaluator &evaluator,
215215
if (auto ClangD = ClangN.getAsDecl()) {
216216
bool Ignore = clang::index::generateUSRForDecl(ClangD, Buffer);
217217
if (!Ignore) {
218-
return std::string(Buffer);
218+
return std::string(Buffer.str());
219219
} else {
220220
return std::string();
221221
}
@@ -229,7 +229,7 @@ swift::USRGenerationRequest::evaluate(Evaluator &evaluator,
229229
ClangMacroInfo->getDefinitionLoc(),
230230
Importer.getClangASTContext().getSourceManager(), Buffer);
231231
if (!Ignore)
232-
return std::string(Buffer);
232+
return std::string(Buffer.str());
233233
else
234234
return std::string();
235235
}

lib/ClangImporter/ClangImporter.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ getNormalInvocationArguments(std::vector<std::string> &invocationArgStrs,
482482
shimsPath = searchPathOpts.SDKPath;
483483
llvm::sys::path::append(shimsPath, "usr", "lib", "swift", "shims");
484484
invocationArgStrs.insert(invocationArgStrs.end(),
485-
{"-isystem", std::string(shimsPath)});
485+
{"-isystem", std::string(shimsPath.str())});
486486
}
487487

488488
// Construct the invocation arguments for the current target.
@@ -637,7 +637,7 @@ getNormalInvocationArguments(std::vector<std::string> &invocationArgStrs,
637637
llvm::sys::path::native(path);
638638

639639
invocationArgStrs.push_back("-isystem");
640-
invocationArgStrs.push_back(std::string(path));
640+
invocationArgStrs.push_back(std::string(path.str()));
641641
} else {
642642
// On Darwin, Clang uses -isysroot to specify the include
643643
// system root. On other targets, it seems to use --sysroot.
@@ -749,7 +749,7 @@ addCommonInvocationArguments(std::vector<std::string> &invocationArgStrs,
749749

750750
// Set the Clang resource directory to the path we computed.
751751
invocationArgStrs.push_back("-resource-dir");
752-
invocationArgStrs.push_back(std::string(resourceDir));
752+
invocationArgStrs.push_back(std::string(resourceDir.str()));
753753
} else {
754754
invocationArgStrs.push_back("-resource-dir");
755755
invocationArgStrs.push_back(overrideResourceDir);

lib/Driver/ToolChains.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1297,13 +1297,13 @@ void ToolChain::getRuntimeLibraryPaths(SmallVectorImpl<std::string> &runtimeLibP
12971297
StringRef SDKPath, bool shared) const {
12981298
SmallString<128> scratchPath;
12991299
getResourceDirPath(scratchPath, args, shared);
1300-
runtimeLibPaths.push_back(std::string(scratchPath));
1300+
runtimeLibPaths.push_back(std::string(scratchPath.str()));
13011301

13021302
// If there's a secondary resource dir, add it too.
13031303
scratchPath.clear();
13041304
getSecondaryResourceDirPath(scratchPath, runtimeLibPaths[0]);
13051305
if (!scratchPath.empty())
1306-
runtimeLibPaths.push_back(std::string(scratchPath));
1306+
runtimeLibPaths.push_back(std::string(scratchPath.str()));
13071307

13081308
if (!SDKPath.empty()) {
13091309
if (!scratchPath.empty()) {
@@ -1312,12 +1312,12 @@ void ToolChain::getRuntimeLibraryPaths(SmallVectorImpl<std::string> &runtimeLibP
13121312
scratchPath = SDKPath;
13131313
llvm::sys::path::append(scratchPath, "System", "iOSSupport");
13141314
llvm::sys::path::append(scratchPath, "usr", "lib", "swift");
1315-
runtimeLibPaths.push_back(std::string(scratchPath));
1315+
runtimeLibPaths.push_back(std::string(scratchPath.str()));
13161316
}
13171317

13181318
scratchPath = SDKPath;
13191319
llvm::sys::path::append(scratchPath, "usr", "lib", "swift");
1320-
runtimeLibPaths.push_back(std::string(scratchPath));
1320+
runtimeLibPaths.push_back(std::string(scratchPath.str()));
13211321
}
13221322
}
13231323

lib/Frontend/ArgsToFrontendOutputsConverter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ OutputFilesComputer::deriveOutputFileFromParts(StringRef dir,
222222
llvm::SmallString<128> path(dir);
223223
llvm::sys::path::append(path, base);
224224
llvm::sys::path::replace_extension(path, Suffix);
225-
return std::string(path);
225+
return std::string(path.str());
226226
}
227227

228228
SupplementaryOutputPathsComputer::SupplementaryOutputPathsComputer(

lib/Frontend/CompilerInvocation.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ void CompilerInvocation::setMainExecutablePath(StringRef Path) {
5656
llvm::sys::path::remove_filename(DiagnosticDocsPath); // Remove /bin
5757
llvm::sys::path::append(DiagnosticDocsPath, "share", "doc", "swift",
5858
"diagnostics");
59-
DiagnosticOpts.DiagnosticDocumentationPath = std::string(DiagnosticDocsPath);
59+
DiagnosticOpts.DiagnosticDocumentationPath = std::string(DiagnosticDocsPath.str());
6060
}
6161

6262
void CompilerInvocation::setDefaultPrebuiltCacheIfNecessary() {
@@ -89,7 +89,7 @@ static void updateRuntimeLibraryPaths(SearchPathOptions &SearchPathOpts,
8989

9090
llvm::sys::path::append(LibPath, LibSubDir);
9191
SearchPathOpts.RuntimeLibraryPaths.clear();
92-
SearchPathOpts.RuntimeLibraryPaths.push_back(std::string(LibPath));
92+
SearchPathOpts.RuntimeLibraryPaths.push_back(std::string(LibPath.str()));
9393
if (Triple.isOSDarwin())
9494
SearchPathOpts.RuntimeLibraryPaths.push_back(DARWIN_OS_LIBRARY_PATH);
9595

@@ -103,14 +103,14 @@ static void updateRuntimeLibraryPaths(SearchPathOptions &SearchPathOpts,
103103

104104
if (!Triple.isOSDarwin())
105105
llvm::sys::path::append(LibPath, swift::getMajorArchitectureName(Triple));
106-
SearchPathOpts.RuntimeLibraryImportPaths.push_back(std::string(LibPath));
106+
SearchPathOpts.RuntimeLibraryImportPaths.push_back(std::string(LibPath.str()));
107107

108108
if (!SearchPathOpts.SDKPath.empty()) {
109109
if (tripleIsMacCatalystEnvironment(Triple)) {
110110
LibPath = SearchPathOpts.SDKPath;
111111
llvm::sys::path::append(LibPath, "System", "iOSSupport");
112112
llvm::sys::path::append(LibPath, "usr", "lib", "swift");
113-
SearchPathOpts.RuntimeLibraryImportPaths.push_back(std::string(LibPath));
113+
SearchPathOpts.RuntimeLibraryImportPaths.push_back(std::string(LibPath.str()));
114114
}
115115

116116
LibPath = SearchPathOpts.SDKPath;
@@ -119,7 +119,7 @@ static void updateRuntimeLibraryPaths(SearchPathOptions &SearchPathOpts,
119119
llvm::sys::path::append(LibPath, getPlatformNameForTriple(Triple));
120120
llvm::sys::path::append(LibPath, swift::getMajorArchitectureName(Triple));
121121
}
122-
SearchPathOpts.RuntimeLibraryImportPaths.push_back(std::string(LibPath));
122+
SearchPathOpts.RuntimeLibraryImportPaths.push_back(std::string(LibPath.str()));
123123
}
124124
}
125125

@@ -751,7 +751,7 @@ static bool ParseSearchPathArgs(SearchPathOptions &Opts,
751751
return searchPath.str();
752752
SmallString<64> fullPath{workingDirectory};
753753
path::append(fullPath, searchPath);
754-
return std::string(fullPath);
754+
return std::string(fullPath.str());
755755
};
756756

757757
for (const Arg *A : Args.filtered(OPT_I)) {
@@ -1160,7 +1160,7 @@ static bool ParseIRGenArgs(IRGenOptions &Opts, ArgList &Args,
11601160
// TODO: Should we support -fdebug-compilation-dir?
11611161
llvm::SmallString<256> cwd;
11621162
llvm::sys::fs::current_path(cwd);
1163-
Opts.DebugCompilationDir = std::string(cwd);
1163+
Opts.DebugCompilationDir = std::string(cwd.str());
11641164
}
11651165

11661166
if (const Arg *A = Args.getLastArg(options::OPT_debug_info_format)) {
@@ -1484,8 +1484,8 @@ static bool ParseMigratorArgs(MigratorOptions &Opts,
14841484
llvm::SmallString<128> authoredDataPath(basePath);
14851485
llvm::sys::path::append(authoredDataPath, getScriptFileName("overlay", langVer));
14861486
// Add authored list first to take higher priority.
1487-
Opts.APIDigesterDataStorePaths.push_back(std::string(authoredDataPath));
1488-
Opts.APIDigesterDataStorePaths.push_back(std::string(dataPath));
1487+
Opts.APIDigesterDataStorePaths.push_back(std::string(authoredDataPath.str()));
1488+
Opts.APIDigesterDataStorePaths.push_back(std::string(dataPath.str()));
14891489
}
14901490
}
14911491

lib/FrontendTool/FrontendTool.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1759,7 +1759,7 @@ static bool dumpAPI(ModuleDecl *Mod, StringRef OutDir) {
17591759
SmallString<256> Path = OutDir;
17601760
StringRef Filename = SF->getFilename();
17611761
path::append(Path, path::filename(Filename));
1762-
return std::string(Path);
1762+
return std::string(Path.str());
17631763
};
17641764

17651765
std::unordered_set<std::string> Filenames;

lib/IDE/CodeCompletionCache.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ static std::string getName(StringRef cacheDirectory,
437437
llvm::APInt(64, uint64_t(hash)).toStringUnsigned(hashStr, /*Radix*/ 36);
438438
OSS << "-" << hashStr << ".completions";
439439

440-
return std::string(name);
440+
return std::string(name.str());
441441
}
442442

443443
Optional<CodeCompletionCache::ValueRefCntPtr>

lib/IDE/Utils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ bool ide::initInvocationByClangArguments(ArrayRef<const char *> ArgList,
346346
llvm::SmallString<64> Str;
347347
Str += "-fmodule-name=";
348348
Str += ClangInvok->getLangOpts()->CurrentModule;
349-
CCArgs.push_back(std::string(Str));
349+
CCArgs.push_back(std::string(Str.str()));
350350
}
351351

352352
if (PPOpts.DetailedRecord) {

lib/Index/IndexRecord.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ emitDataForSwiftSerializedModule(ModuleDecl *module,
524524

525525
std::string outRecordFile;
526526
failed =
527-
failed || writeRecord(tracker, std::string(fileNameWithGroup),
527+
failed || writeRecord(tracker, std::string(fileNameWithGroup.str()),
528528
indexStorePath.str(), &diags, outRecordFile);
529529
if (failed)
530530
return false;

0 commit comments

Comments
 (0)