diff options
44 files changed, 126 insertions, 128 deletions
diff --git a/clang/lib/Basic/FileManager.cpp b/clang/lib/Basic/FileManager.cpp index 214e0f35a52..c46e2c7db38 100644 --- a/clang/lib/Basic/FileManager.cpp +++ b/clang/lib/Basic/FileManager.cpp @@ -430,7 +430,7 @@ FileManager::getBufferForFile(const FileEntry *Entry, bool isVolatile, SmallString<128> FilePath(Entry->getName()); FixupRelativePath(FilePath); - return FS->getBufferForFile(FilePath.str(), FileSize, + return FS->getBufferForFile(FilePath, FileSize, /*RequiresNullTerminator=*/true, isVolatile); } diff --git a/clang/lib/Basic/VirtualFileSystem.cpp b/clang/lib/Basic/VirtualFileSystem.cpp index c89195e9326..5164bcffaf4 100644 --- a/clang/lib/Basic/VirtualFileSystem.cpp +++ b/clang/lib/Basic/VirtualFileSystem.cpp @@ -1134,7 +1134,7 @@ VFSFromYamlDirIterImpl::VFSFromYamlDirIterImpl(const Twine &_Path, if (Current != End) { SmallString<128> PathStr(Dir); llvm::sys::path::append(PathStr, (*Current)->getName()); - llvm::ErrorOr<vfs::Status> S = FS.status(PathStr.str()); + llvm::ErrorOr<vfs::Status> S = FS.status(PathStr); if (S) CurrentEntry = *S; else @@ -1147,7 +1147,7 @@ std::error_code VFSFromYamlDirIterImpl::increment() { if (++Current != End) { SmallString<128> PathStr(Dir); llvm::sys::path::append(PathStr, (*Current)->getName()); - llvm::ErrorOr<vfs::Status> S = FS.status(PathStr.str()); + llvm::ErrorOr<vfs::Status> S = FS.status(PathStr); if (!S) return S.getError(); CurrentEntry = *S; diff --git a/clang/lib/Driver/CrossWindowsToolChain.cpp b/clang/lib/Driver/CrossWindowsToolChain.cpp index 03fe41b74fe..82456e76c75 100644 --- a/clang/lib/Driver/CrossWindowsToolChain.cpp +++ b/clang/lib/Driver/CrossWindowsToolChain.cpp @@ -60,7 +60,7 @@ AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs, if (!DriverArgs.hasArg(options::OPT_nobuiltininc)) { SmallString<128> ResourceDir(D.ResourceDir); llvm::sys::path::append(ResourceDir, "include"); - addSystemInclude(DriverArgs, CC1Args, ResourceDir.str()); + addSystemInclude(DriverArgs, CC1Args, ResourceDir); } addExternCSystemInclude(DriverArgs, CC1Args, SysRoot + "/usr/include"); } diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 509f37904a7..c619c8caa99 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -979,7 +979,7 @@ static bool DiagnoseInputExistence(const Driver &D, const DerivedArgList &Args, SmallString<64> Path(Value); if (Arg *WorkDir = Args.getLastArg(options::OPT_working_directory)) { - if (!llvm::sys::path::is_absolute(Path.str())) { + if (!llvm::sys::path::is_absolute(Path)) { SmallString<64> Directory(WorkDir->getValue()); llvm::sys::path::append(Directory, Value); Path.assign(Directory); @@ -992,7 +992,7 @@ static bool DiagnoseInputExistence(const Driver &D, const DerivedArgList &Args, if (D.IsCLMode() && llvm::sys::Process::FindInEnvPath("LIB", Value)) return true; - D.Diag(clang::diag::err_drv_no_such_file) << Path.str(); + D.Diag(clang::diag::err_drv_no_such_file) << Path; return false; } diff --git a/clang/lib/Driver/MSVCToolChain.cpp b/clang/lib/Driver/MSVCToolChain.cpp index 874e5409dc2..7739cb0cf5c 100644 --- a/clang/lib/Driver/MSVCToolChain.cpp +++ b/clang/lib/Driver/MSVCToolChain.cpp @@ -424,7 +424,7 @@ void MSVCToolChain::AddSystemIncludeWithSubfolder(const ArgList &DriverArgs, const char *subfolder) const { llvm::SmallString<128> path(folder); llvm::sys::path::append(path, subfolder); - addSystemInclude(DriverArgs, CC1Args, path.str()); + addSystemInclude(DriverArgs, CC1Args, path); } void MSVCToolChain::AddClangSystemIncludeArgs(const ArgList &DriverArgs, @@ -435,7 +435,7 @@ void MSVCToolChain::AddClangSystemIncludeArgs(const ArgList &DriverArgs, if (!DriverArgs.hasArg(options::OPT_nobuiltininc)) { SmallString<128> P(getDriver().ResourceDir); llvm::sys::path::append(P, "include"); - addSystemInclude(DriverArgs, CC1Args, P.str()); + addSystemInclude(DriverArgs, CC1Args, P); } if (DriverArgs.hasArg(options::OPT_nostdlibinc)) diff --git a/clang/lib/Driver/Multilib.cpp b/clang/lib/Driver/Multilib.cpp index 1f5d62f247c..b503acc2557 100644 --- a/clang/lib/Driver/Multilib.cpp +++ b/clang/lib/Driver/Multilib.cpp @@ -197,7 +197,7 @@ static Multilib compose(const Multilib &Base, const Multilib &New) { llvm::sys::path::append(IncludeSuffix, "/", Base.includeSuffix(), New.includeSuffix()); - Multilib Composed(GCCSuffix.str(), OSSuffix.str(), IncludeSuffix.str()); + Multilib Composed(GCCSuffix, OSSuffix, IncludeSuffix); Multilib::flags_list &Flags = Composed.flags(); diff --git a/clang/lib/Driver/ToolChains.cpp b/clang/lib/Driver/ToolChains.cpp index 93e6db82935..e358c4e04dc 100644 --- a/clang/lib/Driver/ToolChains.cpp +++ b/clang/lib/Driver/ToolChains.cpp @@ -302,8 +302,8 @@ void MachO::AddLinkRuntimeLib(const ArgList &Args, ArgStringList &CmdArgs, // For now, allow missing resource libraries to support developers who may // not have compiler-rt checked out or integrated into their build (unless // we explicitly force linking with this library). - if (AlwaysLink || llvm::sys::fs::exists(P.str())) - CmdArgs.push_back(Args.MakeArgString(P.str())); + if (AlwaysLink || llvm::sys::fs::exists(P)) + CmdArgs.push_back(Args.MakeArgString(P)); // Adding the rpaths might negatively interact when other rpaths are involved, // so we should make sure we add the rpaths last, after all user-specified @@ -320,7 +320,7 @@ void MachO::AddLinkRuntimeLib(const ArgList &Args, ArgStringList &CmdArgs, // Add the path to the resource dir to rpath to support using the dylib // from the default location without copying. CmdArgs.push_back("-rpath"); - CmdArgs.push_back(Args.MakeArgString(Dir.str())); + CmdArgs.push_back(Args.MakeArgString(Dir)); } } @@ -599,11 +599,11 @@ void DarwinClang::AddCXXStdlibLibArgs(const ArgList &Args, SmallString<128> P(A->getValue()); llvm::sys::path::append(P, "usr", "lib", "libstdc++.dylib"); - if (!llvm::sys::fs::exists(P.str())) { + if (!llvm::sys::fs::exists(P)) { llvm::sys::path::remove_filename(P); llvm::sys::path::append(P, "libstdc++.6.dylib"); - if (llvm::sys::fs::exists(P.str())) { - CmdArgs.push_back(Args.MakeArgString(P.str())); + if (llvm::sys::fs::exists(P)) { + CmdArgs.push_back(Args.MakeArgString(P)); return; } } @@ -646,8 +646,8 @@ void DarwinClang::AddCCKextLibArgs(const ArgList &Args, // For now, allow missing resource libraries to support developers who may // not have compiler-rt checked out or integrated into their build. - if (llvm::sys::fs::exists(P.str())) - CmdArgs.push_back(Args.MakeArgString(P.str())); + if (llvm::sys::fs::exists(P)) + CmdArgs.push_back(Args.MakeArgString(P)); } DerivedArgList *MachO::TranslateArgs(const DerivedArgList &Args, @@ -2249,7 +2249,7 @@ void Hexagon_TC::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs, llvm::sys::path::append(IncludeDir, "hexagon/include/c++/"); llvm::sys::path::append(IncludeDir, Ver); - addSystemInclude(DriverArgs, CC1Args, IncludeDir.str()); + addSystemInclude(DriverArgs, CC1Args, IncludeDir); } ToolChain::CXXStdlibType @@ -3147,7 +3147,7 @@ void Linux::AddClangSystemIncludeArgs(const ArgList &DriverArgs, if (!DriverArgs.hasArg(options::OPT_nobuiltininc)) { SmallString<128> P(D.ResourceDir); llvm::sys::path::append(P, "include"); - addSystemInclude(DriverArgs, CC1Args, P.str()); + addSystemInclude(DriverArgs, CC1Args, P); } if (DriverArgs.hasArg(options::OPT_nostdlibinc)) diff --git a/clang/lib/Driver/Tools.cpp b/clang/lib/Driver/Tools.cpp index 681a9a38850..74c5b7f8d2e 100644 --- a/clang/lib/Driver/Tools.cpp +++ b/clang/lib/Driver/Tools.cpp @@ -382,19 +382,19 @@ void Clang::AddPreprocessingOptions(Compilation &C, P += ".dummy"; if (UsePCH) { llvm::sys::path::replace_extension(P, "pch"); - if (llvm::sys::fs::exists(P.str())) + if (llvm::sys::fs::exists(P)) FoundPCH = true; } if (!FoundPCH) { llvm::sys::path::replace_extension(P, "pth"); - if (llvm::sys::fs::exists(P.str())) + if (llvm::sys::fs::exists(P)) FoundPTH = true; } if (!FoundPCH && !FoundPTH) { llvm::sys::path::replace_extension(P, "gch"); - if (llvm::sys::fs::exists(P.str())) { + if (llvm::sys::fs::exists(P)) { FoundPCH = UsePCH; FoundPTH = !UsePCH; } @@ -407,12 +407,12 @@ void Clang::AddPreprocessingOptions(Compilation &C, CmdArgs.push_back("-include-pch"); else CmdArgs.push_back("-include-pth"); - CmdArgs.push_back(Args.MakeArgString(P.str())); + CmdArgs.push_back(Args.MakeArgString(P)); continue; } else { // Ignore the PCH if not first on command line and emit warning. D.Diag(diag::warn_drv_pch_not_first_include) - << P.str() << A->getAsString(Args); + << P << A->getAsString(Args); } } } @@ -3377,10 +3377,10 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, } else { CoverageFilename = llvm::sys::path::filename(Output.getBaseInput()); } - if (llvm::sys::path::is_relative(CoverageFilename.str())) { + if (llvm::sys::path::is_relative(CoverageFilename)) { SmallString<128> Pwd; if (!llvm::sys::fs::current_path(Pwd)) { - llvm::sys::path::append(Pwd, CoverageFilename.str()); + llvm::sys::path::append(Pwd, CoverageFilename); CoverageFilename.swap(Pwd); } } @@ -4603,7 +4603,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, Flags += EscapedArg; } CmdArgs.push_back("-dwarf-debug-flags"); - CmdArgs.push_back(Args.MakeArgString(Flags.str())); + CmdArgs.push_back(Args.MakeArgString(Flags)); } // Add the split debug info name to the command lines here so we @@ -5063,7 +5063,7 @@ void ClangAs::ConstructJob(Compilation &C, const JobAction &JA, Flags += EscapedArg; } CmdArgs.push_back("-dwarf-debug-flags"); - CmdArgs.push_back(Args.MakeArgString(Flags.str())); + CmdArgs.push_back(Args.MakeArgString(Flags)); } // FIXME: Add -static support, once we have it. @@ -8135,7 +8135,7 @@ void visualstudio::Link::ConstructJob(Compilation &C, const JobAction &JA, SmallString<128> ImplibName(Output.getFilename()); llvm::sys::path::replace_extension(ImplibName, "lib"); CmdArgs.push_back(Args.MakeArgString(std::string("-implib:") + - ImplibName.str())); + ImplibName)); } if (TC.getSanitizerArgs().needsAsanRt()) { diff --git a/clang/lib/Edit/EditedSource.cpp b/clang/lib/Edit/EditedSource.cpp index 1c66cb82770..a5b5875b19d 100644 --- a/clang/lib/Edit/EditedSource.cpp +++ b/clang/lib/Edit/EditedSource.cpp @@ -135,7 +135,7 @@ bool EditedSource::commitInsertFromRange(SourceLocation OrigLoc, StrVec += text; } - return commitInsert(OrigLoc, Offs, StrVec.str(), beforePreviousInsertions); + return commitInsert(OrigLoc, Offs, StrVec, beforePreviousInsertions); } void EditedSource::commitRemove(SourceLocation OrigLoc, @@ -360,14 +360,14 @@ void EditedSource::applyRewrites(EditsReceiver &receiver) { continue; } - applyRewrite(receiver, StrVec.str(), CurOffs, CurLen, SourceMgr, LangOpts); + applyRewrite(receiver, StrVec, CurOffs, CurLen, SourceMgr, LangOpts); CurOffs = offs; StrVec = act.Text; CurLen = act.RemoveLen; CurEnd = CurOffs.getWithOffset(CurLen); } - applyRewrite(receiver, StrVec.str(), CurOffs, CurLen, SourceMgr, LangOpts); + applyRewrite(receiver, StrVec, CurOffs, CurLen, SourceMgr, LangOpts); } void EditedSource::clearRewrites() { diff --git a/clang/lib/Frontend/ASTUnit.cpp b/clang/lib/Frontend/ASTUnit.cpp index bd9961edc29..692edc40a45 100644 --- a/clang/lib/Frontend/ASTUnit.cpp +++ b/clang/lib/Frontend/ASTUnit.cpp @@ -2433,7 +2433,7 @@ bool ASTUnit::Save(StringRef File) { TempPath = File; TempPath += "-%%%%%%%%"; int fd; - if (llvm::sys::fs::createUniqueFile(TempPath.str(), fd, TempPath)) + if (llvm::sys::fs::createUniqueFile(TempPath, fd, TempPath)) return true; // FIXME: Can we somehow regenerate the stat cache here, or do we need to @@ -2447,8 +2447,8 @@ bool ASTUnit::Save(StringRef File) { return true; } - if (llvm::sys::fs::rename(TempPath.str(), File)) { - llvm::sys::fs::remove(TempPath.str()); + if (llvm::sys::fs::rename(TempPath, File)) { + llvm::sys::fs::remove(TempPath); return true; } diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp index ee8c4032caf..b23baa5dbbd 100644 --- a/clang/lib/Frontend/CompilerInstance.cpp +++ b/clang/lib/Frontend/CompilerInstance.cpp @@ -536,7 +536,7 @@ void CompilerInstance::clearOutputFiles(bool EraseFiles) { // relative to that. FileMgr->FixupRelativePath(NewOutFile); if (std::error_code ec = - llvm::sys::fs::rename(it->TempFilename, NewOutFile.str())) { + llvm::sys::fs::rename(it->TempFilename, NewOutFile)) { getDiagnostics().Report(diag::err_unable_to_rename_temp) << it->TempFilename << it->Filename << ec.message(); @@ -641,14 +641,14 @@ llvm::raw_fd_ostream *CompilerInstance::createOutputFile( TempPath += "-%%%%%%%%"; int fd; std::error_code EC = - llvm::sys::fs::createUniqueFile(TempPath.str(), fd, TempPath); + llvm::sys::fs::createUniqueFile(TempPath, fd, TempPath); if (CreateMissingDirectories && EC == llvm::errc::no_such_file_or_directory) { StringRef Parent = llvm::sys::path::parent_path(OutputPath); EC = llvm::sys::fs::create_directories(Parent); if (!EC) { - EC = llvm::sys::fs::createUniqueFile(TempPath.str(), fd, TempPath); + EC = llvm::sys::fs::createUniqueFile(TempPath, fd, TempPath); } } @@ -1191,8 +1191,7 @@ static void pruneModuleCache(const HeaderSearchOptions &HSOpts) { std::error_code EC; SmallString<128> ModuleCachePathNative; llvm::sys::path::native(HSOpts.ModuleCachePath, ModuleCachePathNative); - for (llvm::sys::fs::directory_iterator - Dir(ModuleCachePathNative.str(), EC), DirEnd; + for (llvm::sys::fs::directory_iterator Dir(ModuleCachePathNative, EC), DirEnd; Dir != DirEnd && !EC; Dir.increment(EC)) { // If we don't have a directory, there's nothing to look into. if (!llvm::sys::fs::is_directory(Dir->path())) diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index cbe5435d041..3c818b02fdc 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -2037,7 +2037,7 @@ std::string CompilerInvocation::getModuleHash() const { llvm::sys::path::append(systemVersionFile, "SystemVersion.plist"); llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> buffer = - llvm::MemoryBuffer::getFile(systemVersionFile.str()); + llvm::MemoryBuffer::getFile(systemVersionFile); if (buffer) { code = hash_combine(code, buffer.get()->getBuffer()); diff --git a/clang/lib/Frontend/FrontendAction.cpp b/clang/lib/Frontend/FrontendAction.cpp index 75670d9a202..fd251acc4f9 100644 --- a/clang/lib/Frontend/FrontendAction.cpp +++ b/clang/lib/Frontend/FrontendAction.cpp @@ -268,7 +268,7 @@ bool FrontendAction::BeginSourceFile(CompilerInstance &CI, SmallString<128> DirNative; llvm::sys::path::native(PCHDir->getName(), DirNative); bool Found = false; - for (llvm::sys::fs::directory_iterator Dir(DirNative.str(), EC), DirEnd; + for (llvm::sys::fs::directory_iterator Dir(DirNative, EC), DirEnd; Dir != DirEnd && !EC; Dir.increment(EC)) { // Check whether this is an acceptable AST file. if (ASTReader::isAcceptableASTFile(Dir->path(), FileMgr, diff --git a/clang/lib/Frontend/FrontendActions.cpp b/clang/lib/Frontend/FrontendActions.cpp index 8d600a10f8d..da08937b728 100644 --- a/clang/lib/Frontend/FrontendActions.cpp +++ b/clang/lib/Frontend/FrontendActions.cpp @@ -209,7 +209,7 @@ collectModuleHeaderIncludes(const LangOptions &LangOpts, FileManager &FileMgr, std::error_code EC; SmallString<128> DirNative; llvm::sys::path::native(UmbrellaDir->getName(), DirNative); - for (llvm::sys::fs::recursive_directory_iterator Dir(DirNative.str(), EC), + for (llvm::sys::fs::recursive_directory_iterator Dir(DirNative, EC), DirEnd; Dir != DirEnd && !EC; Dir.increment(EC)) { // Check whether this entry has an extension typically associated with diff --git a/clang/lib/Frontend/InitHeaderSearch.cpp b/clang/lib/Frontend/InitHeaderSearch.cpp index c4d46853b93..9b4f7e5180c 100644 --- a/clang/lib/Frontend/InitHeaderSearch.cpp +++ b/clang/lib/Frontend/InitHeaderSearch.cpp @@ -247,7 +247,7 @@ void InitHeaderSearch::AddDefaultCIncludePaths(const llvm::Triple &triple, // supplied path. SmallString<128> P = StringRef(HSOpts.ResourceDir); llvm::sys::path::append(P, "include"); - AddUnmappedPath(P.str(), ExternCSystem, false); + AddUnmappedPath(P, ExternCSystem, false); } // All remaining additions are for system include directories, early exit if @@ -275,7 +275,7 @@ void InitHeaderSearch::AddDefaultCIncludePaths(const llvm::Triple &triple, // <sysroot>/<triple>/include SmallString<128> P = StringRef(HSOpts.ResourceDir); llvm::sys::path::append(P, "../../..", triple.str(), "include"); - AddPath(P.str(), System, false); + AddPath(P, System, false); break; } @@ -326,18 +326,18 @@ void InitHeaderSearch::AddDefaultCIncludePaths(const llvm::Triple &triple, // <sysroot>/i686-w64-mingw32/include SmallString<128> P = StringRef(HSOpts.ResourceDir); llvm::sys::path::append(P, "../../../i686-w64-mingw32/include"); - AddPath(P.str(), System, false); + AddPath(P, System, false); // <sysroot>/x86_64-w64-mingw32/include P.resize(HSOpts.ResourceDir.size()); llvm::sys::path::append(P, "../../../x86_64-w64-mingw32/include"); - AddPath(P.str(), System, false); + AddPath(P, System, false); // mingw.org crt include paths // <sysroot>/include P.resize(HSOpts.ResourceDir.size()); llvm::sys::path::append(P, "../../../include"); - AddPath(P.str(), System, false); + AddPath(P, System, false); AddPath("/mingw/include", System, false); #if defined(LLVM_ON_WIN32) AddPath("c:/mingw/include", System, false); @@ -503,7 +503,7 @@ void InitHeaderSearch::AddDefaultIncludePaths(const LangOptions &Lang, // Get foo/include/c++/v1 llvm::sys::path::append(P, "include", "c++", "v1"); - AddUnmappedPath(P.str(), CXXSystem, false); + AddUnmappedPath(P, CXXSystem, false); } } // On Solaris, include the support directory for things like xlocale and @@ -714,7 +714,7 @@ void clang::ApplyHeaderSearchOptions(HeaderSearch &HS, // Set up the builtin include directory in the module map. SmallString<128> P = StringRef(HSOpts.ResourceDir); llvm::sys::path::append(P, "include"); - if (const DirectoryEntry *Dir = HS.getFileMgr().getDirectory(P.str())) + if (const DirectoryEntry *Dir = HS.getFileMgr().getDirectory(P)) HS.getModuleMap().setBuiltinIncludeDir(Dir); } diff --git a/clang/lib/Frontend/ModuleDependencyCollector.cpp b/clang/lib/Frontend/ModuleDependencyCollector.cpp index 62865e984f6..67852dc0203 100644 --- a/clang/lib/Frontend/ModuleDependencyCollector.cpp +++ b/clang/lib/Frontend/ModuleDependencyCollector.cpp @@ -77,10 +77,10 @@ std::error_code ModuleDependencyListener::copyToRoot(StringRef Src) { if (std::error_code EC = fs::create_directories(path::parent_path(Dest), /*IgnoreExisting=*/true)) return EC; - if (std::error_code EC = fs::copy_file(AbsoluteSrc.str(), Dest.str())) + if (std::error_code EC = fs::copy_file(AbsoluteSrc, Dest)) return EC; // Use the absolute path under the root for the file mapping. - Collector.addFileMapping(AbsoluteSrc.str(), Dest.str()); + Collector.addFileMapping(AbsoluteSrc, Dest); return std::error_code(); } diff --git a/clang/lib/Frontend/SerializedDiagnosticPrinter.cpp b/clang/lib/Frontend/SerializedDiagnosticPrinter.cpp index ec9c0a93b15..5dcacfadf26 100644 --- a/clang/lib/Frontend/SerializedDiagnosticPrinter.cpp +++ b/clang/lib/Frontend/SerializedDiagnosticPrinter.cpp @@ -632,7 +632,7 @@ void SDiagsWriter::HandleDiagnostic(DiagnosticsEngine::Level DiagLevel, "Unexpected diagnostic with valid location outside of a source file"); SDiagsRenderer Renderer(*this, *LangOpts, &*State->DiagOpts); Renderer.emitDiagnostic(Info.getLocation(), DiagLevel, - State->diagBuf.str(), + State->diagBuf, Info.getRanges(), Info.getFixItHints(), &Info.getSourceManager(), diff --git a/clang/lib/Lex/HeaderSearch.cpp b/clang/lib/Lex/HeaderSearch.cpp index b94cdbd1cbf..3e59cdbd186 100644 --- a/clang/lib/Lex/HeaderSearch.cpp +++ b/clang/lib/Lex/HeaderSearch.cpp @@ -149,7 +149,7 @@ std::string HeaderSearch::getModuleFileName(StringRef ModuleName, SmallString<128> HashStr; llvm::APInt(64, size_t(Hash)).toStringUnsigned(HashStr, /*Radix*/36); - llvm::sys::path::append(Result, ModuleName + "-" + HashStr.str() + ".pcm"); + llvm::sys::path::append(Result, ModuleName + "-" + HashStr + ".pcm"); } return Result.str().str(); } @@ -297,7 +297,7 @@ const FileEntry *DirectoryLookup::LookupFile( RelativePath->append(Filename.begin(), Filename.end()); } - return getFileAndSuggestModule(HS, TmpDir.str(), getDir(), + return getFileAndSuggestModule(HS, TmpDir, getDir(), isSystemHeaderDirectory(), SuggestedModule); } @@ -438,7 +438,7 @@ const FileEntry *DirectoryLookup::DoFrameworkLookup( HS.IncrementFrameworkLookupCount(); // If the framework dir doesn't exist, we fail. - const DirectoryEntry *Dir = FileMgr.getDirectory(FrameworkName.str()); + const DirectoryEntry *Dir = FileMgr.getDirectory(FrameworkName); if (!Dir) return nullptr; // Otherwise, if it does, remember that this is the right direntry for this @@ -450,7 +450,7 @@ const FileEntry *DirectoryLookup::DoFrameworkLookup( if (getDirCharacteristic() == SrcMgr::C_User) { SmallString<1024> SystemFrameworkMarker(FrameworkName); SystemFrameworkMarker += ".system_framework"; - if (llvm::sys::fs::exists(SystemFrameworkMarker.str())) { + if (llvm::sys::fs::exists(SystemFrameworkMarker)) { CacheEntry.IsUserSpecifiedSystemFramework = true; } } @@ -476,7 +476,7 @@ const FileEntry *DirectoryLookup::DoFrameworkLookup( } FrameworkName.append(Filename.begin()+SlashPos+1, Filename.end()); - const FileEntry *FE = FileMgr.getFile(FrameworkName.str(), + const FileEntry *FE = FileMgr.getFile(FrameworkName, /*openFile=*/!SuggestedModule); if (!FE) { // Check "/System/Library/Frameworks/Cocoa.framework/PrivateHeaders/file.h" @@ -487,7 +487,7 @@ const FileEntry *DirectoryLookup::DoFrameworkLookup( SearchPath->insert(SearchPath->begin()+OrigSize, Private, Private+strlen(Private)); - FE = FileMgr.getFile(FrameworkName.str(), /*openFile=*/!SuggestedModule); + FE = FileMgr.getFile(FrameworkName, /*openFile=*/!SuggestedModule); } // If we found the header and are allowed to suggest a module, do so now. @@ -628,7 +628,7 @@ const FileEntry *HeaderSearch::LookupFile( bool IncluderIsSystemHeader = Includer && getFileInfo(Includer).DirInfo != SrcMgr::C_User; if (const FileEntry *FE = getFileAndSuggestModule( - *this, TmpDir.str(), IncluderAndDir.second, + *this, TmpDir, IncluderAndDir.second, IncluderIsSystemHeader, SuggestedModule)) { if (!Includer) { assert(First && "only first includer can have no file"); @@ -865,7 +865,7 @@ LookupSubframeworkHeader(StringRef Filename, ++NumSubFrameworkLookups; // If the framework dir doesn't exist, we fail. - const DirectoryEntry *Dir = FileMgr.getDirectory(FrameworkName.str()); + const DirectoryEntry *Dir = FileMgr.getDirectory(FrameworkName); if (!Dir) return nullptr; // Otherwise, if it does, remember that this is the right direntry for this @@ -890,7 +890,7 @@ LookupSubframeworkHeader(StringRef Filename, } HeadersFilename.append(Filename.begin()+SlashPos+1, Filename.end()); - if (!(FE = FileMgr.getFile(HeadersFilename.str(), /*openFile=*/true))) { + if (!(FE = FileMgr.getFile(HeadersFilename, /*openFile=*/true))) { // Check ".../Frameworks/HIToolbox.framework/PrivateHeaders/HIToolbox.h" HeadersFilename = FrameworkName; @@ -902,7 +902,7 @@ LookupSubframeworkHeader(StringRef Filename, } HeadersFilename.append(Filename.begin()+SlashPos+1, Filename.end()); - if (!(FE = FileMgr.getFile(HeadersFilename.str(), /*openFile=*/true))) + if (!(FE = FileMgr.getFile(HeadersFilename, /*openFile=*/true))) return nullptr; } @@ -1284,7 +1284,7 @@ void HeaderSearch::collectAllModules(SmallVectorImpl<Module *> &Modules) { DirNative); // Search each of the ".framework" directories to load them as modules. - for (llvm::sys::fs::directory_iterator Dir(DirNative.str(), EC), DirEnd; + for (llvm::sys::fs::directory_iterator Dir(DirNative, EC), DirEnd; Dir != DirEnd && !EC; Dir.increment(EC)) { if (llvm::sys::path::extension(Dir->path()) != ".framework") continue; @@ -1351,7 +1351,7 @@ void HeaderSearch::loadSubdirectoryModuleMaps(DirectoryLookup &SearchDir) { std::error_code EC; SmallString<128> DirNative; llvm::sys::path::native(SearchDir.getDir()->getName(), DirNative); - for (llvm::sys::fs::directory_iterator Dir(DirNative.str(), EC), DirEnd; + for (llvm::sys::fs::directory_iterator Dir(DirNative, EC), DirEnd; Dir != DirEnd && !EC; Dir.increment(EC)) { bool IsFramework = llvm::sys::path::extension(Dir->path()) == ".framework"; if (IsFramework == SearchDir.isFramework()) diff --git a/clang/lib/Lex/ModuleMap.cpp b/clang/lib/Lex/ModuleMap.cpp index b0195af70b6..1134cce84f9 100644 --- a/clang/lib/Lex/ModuleMap.cpp +++ b/clang/lib/Lex/ModuleMap.cpp @@ -733,8 +733,7 @@ Module *ModuleMap::inferFrameworkModule(StringRef ModuleName, = StringRef(FrameworkDir->getName()); llvm::sys::path::append(SubframeworksDirName, "Frameworks"); llvm::sys::path::native(SubframeworksDirName); - for (llvm::sys::fs::directory_iterator - Dir(SubframeworksDirName.str(), EC), DirEnd; + for (llvm::sys::fs::directory_iterator Dir(SubframeworksDirName, EC), DirEnd; Dir != DirEnd && !EC; Dir.increment(EC)) { if (!StringRef(Dir->path()).endswith(".framework")) continue; @@ -1587,7 +1586,7 @@ void ModuleMapParser::parseExternModuleDecl() { if (llvm::sys::path::is_relative(FileNameRef)) { ModuleMapFileName += Directory->getName(); llvm::sys::path::append(ModuleMapFileName, FileName); - FileNameRef = ModuleMapFileName.str(); + FileNameRef = ModuleMapFileName; } if (const FileEntry *File = SourceMgr.getFileManager().getFile(FileNameRef)) Map.parseModuleMapFile( @@ -1734,7 +1733,7 @@ void ModuleMapParser::parseHeaderDecl(MMToken::TokenKind LeadingToken, // Check whether this file is in the public headers. llvm::sys::path::append(RelativePathName, "Headers", Header.FileName); - llvm::sys::path::append(FullPathName, RelativePathName.str()); + llvm::sys::path::append(FullPathName, RelativePathName); File = SourceMgr.getFileManager().getFile(FullPathName); if (!File) { @@ -1744,13 +1743,13 @@ void ModuleMapParser::parseHeaderDecl(MMToken::TokenKind LeadingToken, FullPathName.resize(FullPathLength); llvm::sys::path::append(RelativePathName, "PrivateHeaders", Header.FileName); - llvm::sys::path::append(FullPathName, RelativePathName.str()); + llvm::sys::path::append(FullPathName, RelativePathName); File = SourceMgr.getFileManager().getFile(FullPathName); } } else { // Lookup for normal headers. llvm::sys::path::append(RelativePathName, Header.FileName); - llvm::sys::path::append(FullPathName, RelativePathName.str()); + llvm::sys::path::append(FullPathName, RelativePathName); File = SourceMgr.getFileManager().getFile(FullPathName); // If this is a system module with a top-level header, this header diff --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp index bf0ce72f666..a50c8a82935 100644 --- a/clang/lib/Lex/PPDirectives.cpp +++ b/clang/lib/Lex/PPDirectives.cpp @@ -1233,7 +1233,7 @@ void Preprocessor::HandleUserDiagnosticDirective(Token &Tok, // Find the first non-whitespace character, so that we can make the // diagnostic more succinct. - StringRef Msg = Message.str().ltrim(" "); + StringRef Msg = StringRef(Message).ltrim(" "); if (isWarning) Diag(Tok, diag::pp_hash_warning) << Msg; @@ -1491,7 +1491,7 @@ void Preprocessor::HandleIncludeDirective(SourceLocation HashLoc, FilenameBuffer.push_back('<'); if (ConcatenateIncludeName(FilenameBuffer, End)) return; // Found <eod> but no ">"? Diagnostic already emitted. - Filename = FilenameBuffer.str(); + Filename = FilenameBuffer; CharEnd = End.getLocWithOffset(1); break; default: @@ -1680,9 +1680,9 @@ void Preprocessor::HandleIncludeDirective(SourceLocation HashLoc, CharSourceRange ReplaceRange(SourceRange(HashLoc, CharEnd), /*IsTokenRange=*/false); Diag(HashLoc, diag::warn_auto_module_import) - << IncludeKind << PathString - << FixItHint::CreateReplacement(ReplaceRange, - "@import " + PathString.str().str() + ";"); + << IncludeKind << PathString + << FixItHint::CreateReplacement( + ReplaceRange, ("@import " + PathString + ";").str()); } // Load the module. Only make macros visible. We'll make the declarations diff --git a/clang/lib/Lex/PPMacroExpansion.cpp b/clang/lib/Lex/PPMacroExpansion.cpp index 2994176dcb2..77631815494 100644 --- a/clang/lib/Lex/PPMacroExpansion.cpp +++ b/clang/lib/Lex/PPMacroExpansion.cpp @@ -1131,7 +1131,7 @@ static bool EvaluateHasIncludeCommon(Token &Tok, Tok.setKind(tok::eod); return false; // Found <eod> but no ">"? Diagnostic already emitted. } - Filename = FilenameBuffer.str(); + Filename = FilenameBuffer; break; default: PP.Diag(Tok.getLocation(), diag::err_pp_expects_filename); diff --git a/clang/lib/Lex/Pragma.cpp b/clang/lib/Lex/Pragma.cpp index 0d9c508fd56..bfac3fda297 100644 --- a/clang/lib/Lex/Pragma.cpp +++ b/clang/lib/Lex/Pragma.cpp @@ -648,7 +648,7 @@ void Preprocessor::HandlePragmaIncludeAlias(Token &Tok) { SourceLocation End; if (ConcatenateIncludeName(FileNameBuffer, End)) return; // Diagnostic already emitted - SourceFileName = FileNameBuffer.str(); + SourceFileName = FileNameBuffer; } else { Diag(Tok, diag::warn_pragma_include_alias_expected_filename); return; @@ -679,7 +679,7 @@ void Preprocessor::HandlePragmaIncludeAlias(Token &Tok) { SourceLocation End; if (ConcatenateIncludeName(FileNameBuffer, End)) return; // Diagnostic already emitted - ReplaceFileName = FileNameBuffer.str(); + ReplaceFileName = FileNameBuffer; } else { Diag(Tok, diag::warn_pragma_include_alias_expected_filename); return; diff --git a/clang/lib/Lex/TokenLexer.cpp b/clang/lib/Lex/TokenLexer.cpp index 5f4705eff69..23d72814f31 100644 --- a/clang/lib/Lex/TokenLexer.cpp +++ b/clang/lib/Lex/TokenLexer.cpp @@ -637,7 +637,7 @@ bool TokenLexer::PasteTokens(Token &Tok) { // disabling it. PP.Diag(Loc, PP.getLangOpts().MicrosoftExt ? diag::ext_pp_bad_paste_ms : diag::err_pp_bad_paste) - << Buffer.str(); + << Buffer; } // An error has occurred so exit loop. diff --git a/clang/lib/Parse/ParseInit.cpp b/clang/lib/Parse/ParseInit.cpp index 7fe9862d399..42287d68b33 100644 --- a/clang/lib/Parse/ParseInit.cpp +++ b/clang/lib/Parse/ParseInit.cpp @@ -148,7 +148,7 @@ ExprResult Parser::ParseInitializerWithPotentialDesignator() { Diag(NameLoc, diag::ext_gnu_old_style_field_designator) << FixItHint::CreateReplacement(SourceRange(NameLoc, ColonLoc), - NewSyntax.str()); + NewSyntax); Designation D; D.AddDesignator(Designator::getField(FieldName, SourceLocation(), NameLoc)); diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 743c4ce4d14..2fd231b720b 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -10136,7 +10136,7 @@ void Sema::ActOnFinishKNRParamDeclarations(Scope *S, Declarator &D, << " int " << FTI.Params[i].Ident->getName() << ";\n"; Diag(FTI.Params[i].IdentLoc, diag::ext_param_not_declared) << FTI.Params[i].Ident - << FixItHint::CreateInsertion(LocAfterDecls, Code.str()); + << FixItHint::CreateInsertion(LocAfterDecls, Code); // Implicitly declare the argument as type 'int' for lack of a better // type. diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index a793d45da4e..35a0e39d615 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -7771,7 +7771,7 @@ static void DiagnoseBadShiftValues(Sema& S, ExprResult &LHS, ExprResult &RHS, // turned off separately if needed. if (LeftBits == ResultBits - 1) { S.Diag(Loc, diag::warn_shift_result_sets_sign_bit) - << HexResult.str() << LHSType + << HexResult << LHSType << LHS.get()->getSourceRange() << RHS.get()->getSourceRange(); return; } diff --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp index 1710c976afd..3140090c7be 100644 --- a/clang/lib/Sema/SemaStmt.cpp +++ b/clang/lib/Sema/SemaStmt.cpp @@ -906,12 +906,12 @@ Sema::ActOnFinishSwitchStmt(SourceLocation SwitchLoc, Stmt *Switch, if (PrevString == CurrString) Diag(CaseVals[i].second->getLHS()->getLocStart(), diag::err_duplicate_case) << - (PrevString.empty() ? CaseValStr.str() : PrevString); + (PrevString.empty() ? CaseValStr : PrevString); else Diag(CaseVals[i].second->getLHS()->getLocStart(), diag::err_duplicate_case_differing_expr) << - (PrevString.empty() ? CaseValStr.str() : PrevString) << - (CurrString.empty() ? CaseValStr.str() : CurrString) << + (PrevString.empty() ? CaseValStr : PrevString) << + (CurrString.empty() ? CaseValStr : CurrString) << CaseValStr; Diag(CaseVals[i-1].second->getLHS()->getLocStart(), diff --git a/clang/lib/Serialization/ASTReaderStmt.cpp b/clang/lib/Serialization/ASTReaderStmt.cpp index a1b6c1bf2ee..0f0c7ea9703 100644 --- a/clang/lib/Serialization/ASTReaderStmt.cpp +++ b/clang/lib/Serialization/ASTReaderStmt.cpp @@ -486,7 +486,7 @@ void ASTStmtReader::VisitStringLiteral(StringLiteral *E) { // Read string data SmallString<16> Str(&Record[Idx], &Record[Idx] + Len); - E->setString(Reader.getContext(), Str.str(), kind, isPascal); + E->setString(Reader.getContext(), Str, kind, isPascal); Idx += Len; // Read source locations diff --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp index 10a52f81abc..a8e92b8151c 100644 --- a/clang/lib/Serialization/ASTWriter.cpp +++ b/clang/lib/Serialization/ASTWriter.cpp @@ -1767,7 +1767,7 @@ void ASTWriter::WriteHeaderSearch(const HeaderSearch &HS) { Record.push_back(NumHeaderSearchEntries); Record.push_back(TableData.size()); TableData.append(GeneratorTrait.strings_begin(),GeneratorTrait.strings_end()); - Stream.EmitRecordWithBlob(TableAbbrev, Record, TableData.str()); + Stream.EmitRecordWithBlob(TableAbbrev, Record, TableData); // Free all of the strings we had to duplicate. for (unsigned I = 0, N = SavedStrings.size(); I != N; ++I) @@ -2227,7 +2227,7 @@ void ASTWriter::WritePreprocessor(const Preprocessor &PP, bool IsModule) { Record.push_back(MACRO_TABLE); Record.push_back(BucketOffset); - Stream.EmitRecordWithBlob(MacroTableAbbrev, Record, MacroTable.str()); + Stream.EmitRecordWithBlob(MacroTableAbbrev, Record, MacroTable); Record.clear(); // Write the offsets table for macro IDs. @@ -3061,7 +3061,7 @@ void ASTWriter::WriteSelectors(Sema &SemaRef) { Record.push_back(METHOD_POOL); Record.push_back(BucketOffset); Record.push_back(NumTableEntries); - Stream.EmitRecordWithBlob(MethodPoolAbbrev, Record, MethodPool.str()); + Stream.EmitRecordWithBlob(MethodPoolAbbrev, Record, MethodPool); // Create a blob abbreviation for the selector table offsets. Abbrev = new BitCodeAbbrev(); @@ -3517,7 +3517,7 @@ void ASTWriter::WriteIdentifierTable(Preprocessor &PP, RecordData Record; Record.push_back(IDENTIFIER_TABLE); Record.push_back(BucketOffset); - Stream.EmitRecordWithBlob(IDTableAbbrev, Record, IdentifierTable.str()); + Stream.EmitRecordWithBlob(IDTableAbbrev, Record, IdentifierTable); } // Write the offsets table for identifier IDs. @@ -3835,7 +3835,7 @@ uint64_t ASTWriter::WriteDeclContextVisibleBlock(ASTContext &Context, Record.push_back(DECL_CONTEXT_VISIBLE); Record.push_back(BucketOffset); Stream.EmitRecordWithBlob(DeclContextVisibleLookupAbbrev, Record, - LookupTable.str()); + LookupTable); ++NumVisibleDeclContexts; return Offset; } @@ -3860,7 +3860,7 @@ void ASTWriter::WriteDeclContextVisibleUpdate(const DeclContext *DC) { Record.push_back(UPDATE_VISIBLE); Record.push_back(getDeclID(cast<Decl>(DC))); Record.push_back(BucketOffset); - Stream.EmitRecordWithBlob(UpdateVisibleAbbrev, Record, LookupTable.str()); + Stream.EmitRecordWithBlob(UpdateVisibleAbbrev, Record, LookupTable); } /// \brief Write an FP_PRAGMA_OPTIONS block for the given FPOptions. diff --git a/clang/lib/Serialization/GlobalModuleIndex.cpp b/clang/lib/Serialization/GlobalModuleIndex.cpp index 47913880454..1b52b441134 100644 --- a/clang/lib/Serialization/GlobalModuleIndex.cpp +++ b/clang/lib/Serialization/GlobalModuleIndex.cpp @@ -757,7 +757,7 @@ void GlobalModuleIndexBuilder::writeIndex(llvm::BitstreamWriter &Stream) { Record.clear(); Record.push_back(IDENTIFIER_INDEX); Record.push_back(BucketOffset); - Stream.EmitRecordWithBlob(IDTableAbbrev, Record, IdentifierTable.str()); + Stream.EmitRecordWithBlob(IDTableAbbrev, Record, IdentifierTable); } Stream.ExitBlock(); @@ -841,12 +841,12 @@ GlobalModuleIndex::writeIndex(FileManager &FileMgr, StringRef Path) { return EC_IOError; // Remove the old index file. It isn't relevant any more. - llvm::sys::fs::remove(IndexPath.str()); + llvm::sys::fs::remove(IndexPath); // Rename the newly-written index file to the proper name. - if (llvm::sys::fs::rename(IndexTmpPath.str(), IndexPath.str())) { + if (llvm::sys::fs::rename(IndexTmpPath, IndexPath)) { // Rename failed; just remove the - llvm::sys::fs::remove(IndexTmpPath.str()); + llvm::sys::fs::remove(IndexTmpPath); return EC_IOError; } diff --git a/clang/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp index 4ee02230649..d5172109f92 100644 --- a/clang/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp @@ -162,7 +162,7 @@ void DereferenceChecker::reportBug(ProgramStateRef State, const Stmt *S, os.flush(); BugReport *report = new BugReport(*BT_null, - buf.empty() ? BT_null->getDescription() : buf.str(), + buf.empty() ? BT_null->getDescription() : buf, N); bugreporter::trackNullOrUndefValue(N, bugreporter::getDerefExpr(S), *report); diff --git a/clang/lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp index 1926600b6d6..02c12095b5a 100644 --- a/clang/lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp @@ -336,7 +336,7 @@ const ObjCIvarDecl *IvarInvalidationCheckerImpl::findPropertyBackingIvar( llvm::raw_svector_ostream os(PropNameWithUnderscore); os << '_' << PropName; } - if (IvarName == PropNameWithUnderscore.str()) + if (IvarName == PropNameWithUnderscore) return Iv; } diff --git a/clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp b/clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp index 88b5464d44b..026cc02f630 100644 --- a/clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp +++ b/clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp @@ -282,7 +282,7 @@ void HTMLDiagnostics::ReportDiag(const PathDiagnostic& D, llvm::sys::path::append(Model, Directory, "report-%%%%%%.html"); if (std::error_code EC = - llvm::sys::fs::createUniqueFile(Model.str(), FD, ResultPath)) { + llvm::sys::fs::createUniqueFile(Model, FD, ResultPath)) { llvm::errs() << "warning: could not create file in '" << Directory << "': " << EC.message() << '\n'; return; @@ -302,12 +302,12 @@ void HTMLDiagnostics::ReportDiag(const PathDiagnostic& D, << "-" << i << ".html"; llvm::sys::path::append(Model, Directory, filename.str()); - EC = llvm::sys::fs::openFileForWrite(Model.str(), + EC = llvm::sys::fs::openFileForWrite(Model, FD, llvm::sys::fs::F_RW | llvm::sys::fs::F_Excl); if (EC && EC != std::errc::file_exists) { - llvm::errs() << "warning: could not create file '" << Model.str() + llvm::errs() << "warning: could not create file '" << Model << "': " << EC.message() << '\n'; return; } diff --git a/clang/lib/Tooling/JSONCompilationDatabase.cpp b/clang/lib/Tooling/JSONCompilationDatabase.cpp index 3b5f7e28d02..7dc211e934b 100644 --- a/clang/lib/Tooling/JSONCompilationDatabase.cpp +++ b/clang/lib/Tooling/JSONCompilationDatabase.cpp @@ -176,7 +176,7 @@ JSONCompilationDatabase::getCompileCommands(StringRef FilePath) const { std::string Error; llvm::raw_string_ostream ES(Error); - StringRef Match = MatchTrie.findEquivalent(NativeFilePath.str(), ES); + StringRef Match = MatchTrie.findEquivalent(NativeFilePath, ES); if (Match.empty()) return std::vector<CompileCommand>(); llvm::StringMap< std::vector<CompileCommandRef> >::const_iterator @@ -307,13 +307,13 @@ bool JSONCompilationDatabase::parse(std::string &ErrorMessage) { SmallString<128> AbsolutePath( Directory->getValue(DirectoryStorage)); llvm::sys::path::append(AbsolutePath, FileName); - llvm::sys::path::native(AbsolutePath.str(), NativeFilePath); + llvm::sys::path::native(AbsolutePath, NativeFilePath); } else { llvm::sys::path::native(FileName, NativeFilePath); } IndexByFile[NativeFilePath].push_back( CompileCommandRef(Directory, Command)); - MatchTrie.insert(NativeFilePath.str()); + MatchTrie.insert(NativeFilePath); } return true; } diff --git a/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp b/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp index e5177554177..efce5219031 100644 --- a/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp +++ b/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp @@ -241,7 +241,7 @@ static void groupDiagnostics(const std::vector<Record*> &Diags, Replacement += (*I)->ExplicitDef->getName(); Replacement += ">"; } - SMFixIt FixIt(InGroupRange, Replacement.str()); + SMFixIt FixIt(InGroupRange, Replacement); SrcMgr.PrintMessage(NextDiagGroup->getLoc().front(), SourceMgr::DK_Error, diff --git a/llvm/include/llvm/Support/FileUtilities.h b/llvm/include/llvm/Support/FileUtilities.h index 3f2f176eb46..2ee2c60b996 100644 --- a/llvm/include/llvm/Support/FileUtilities.h +++ b/llvm/include/llvm/Support/FileUtilities.h @@ -51,7 +51,7 @@ namespace llvm { ~FileRemover() { if (DeleteIt) { // Ignore problems deleting the file. - sys::fs::remove(Filename.str()); + sys::fs::remove(Filename); } } @@ -61,7 +61,7 @@ namespace llvm { void setFile(const Twine& filename, bool deleteIt = true) { if (DeleteIt) { // Ignore problems deleting the file. - sys::fs::remove(Filename.str()); + sys::fs::remove(Filename); } Filename.clear(); diff --git a/llvm/lib/MC/MCAsmStreamer.cpp b/llvm/lib/MC/MCAsmStreamer.cpp index 2312cd5ea02..62f5279a84d 100644 --- a/llvm/lib/MC/MCAsmStreamer.cpp +++ b/llvm/lib/MC/MCAsmStreamer.cpp @@ -267,7 +267,7 @@ void MCAsmStreamer::EmitCommentsAndEOL() { } CommentStream.flush(); - StringRef Comments = CommentToEmit.str(); + StringRef Comments = CommentToEmit; assert(Comments.back() == '\n' && "Comment array not newline terminated"); diff --git a/llvm/lib/MC/MCAssembler.cpp b/llvm/lib/MC/MCAssembler.cpp index b3e0b74e2b9..dada94b9dd3 100644 --- a/llvm/lib/MC/MCAssembler.cpp +++ b/llvm/lib/MC/MCAssembler.cpp @@ -789,7 +789,7 @@ static void writeFragment(const MCAssembler &Asm, const MCAsmLayout &Layout, case MCFragment::FT_LEB: { const MCLEBFragment &LF = cast<MCLEBFragment>(F); - OW->WriteBytes(LF.getContents().str()); + OW->WriteBytes(LF.getContents()); break; } @@ -805,12 +805,12 @@ static void writeFragment(const MCAssembler &Asm, const MCAsmLayout &Layout, case MCFragment::FT_Dwarf: { const MCDwarfLineAddrFragment &OF = cast<MCDwarfLineAddrFragment>(F); - OW->WriteBytes(OF.getContents().str()); + OW->WriteBytes(OF.getContents()); break; } case MCFragment::FT_DwarfFrame: { const MCDwarfCallFrameFragment &CF = cast<MCDwarfCallFrameFragment>(F); - OW->WriteBytes(CF.getContents().str()); + OW->WriteBytes(CF.getContents()); break; } } diff --git a/llvm/lib/MC/MCDwarf.cpp b/llvm/lib/MC/MCDwarf.cpp index 3554715bee9..ccfba6691e8 100644 --- a/llvm/lib/MC/MCDwarf.cpp +++ b/llvm/lib/MC/MCDwarf.cpp @@ -1293,7 +1293,7 @@ const MCSymbol &FrameEmitterImpl::EmitCIE(MCObjectStreamer &streamer, Augmentation += "R"; if (IsSignalFrame) Augmentation += "S"; - streamer.EmitBytes(Augmentation.str()); + streamer.EmitBytes(Augmentation); } streamer.EmitIntValue(0, 1); diff --git a/llvm/lib/Support/APInt.cpp b/llvm/lib/Support/APInt.cpp index 4a2a620eab4..dc8a6525c8b 100644 --- a/llvm/lib/Support/APInt.cpp +++ b/llvm/lib/Support/APInt.cpp @@ -2297,7 +2297,7 @@ void APInt::dump() const { void APInt::print(raw_ostream &OS, bool isSigned) const { SmallString<40> S; this->toString(S, 10, isSigned, /* formatAsCLiteral = */false); - OS << S.str(); + OS << S; } // This implements a variety of operations on a representation of diff --git a/llvm/lib/Support/LockFileManager.cpp b/llvm/lib/Support/LockFileManager.cpp index 2a0178bcc5b..a6c17d4e587 100644 --- a/llvm/lib/Support/LockFileManager.cpp +++ b/llvm/lib/Support/LockFileManager.cpp @@ -91,7 +91,7 @@ LockFileManager::LockFileManager(StringRef FileName) UniqueLockFileName += "-%%%%%%%%"; int UniqueLockFileID; if (std::error_code EC = sys::fs::createUniqueFile( - UniqueLockFileName.str(), UniqueLockFileID, UniqueLockFileName)) { + UniqueLockFileName, UniqueLockFileID, UniqueLockFileName)) { Error = EC; return; } @@ -116,7 +116,7 @@ LockFileManager::LockFileManager(StringRef FileName) // We failed to write out PID, so make up an excuse, remove the // unique lock file, and fail. Error = make_error_code(errc::no_space_on_device); - sys::fs::remove(UniqueLockFileName.c_str()); + sys::fs::remove(UniqueLockFileName); return; } } @@ -124,7 +124,7 @@ LockFileManager::LockFileManager(StringRef FileName) while (1) { // Create a link from the lock file name. If this succeeds, we're done. std::error_code EC = - sys::fs::create_link(UniqueLockFileName.str(), LockFileName.str()); + sys::fs::create_link(UniqueLockFileName, LockFileName); if (!EC) return; @@ -137,11 +137,11 @@ LockFileManager::LockFileManager(StringRef FileName) // from the lock file. if ((Owner = readLockFile(LockFileName))) { // Wipe out our unique lock file (it's useless now) - sys::fs::remove(UniqueLockFileName.str()); + sys::fs::remove(UniqueLockFileName); return; } - if (!sys::fs::exists(LockFileName.str())) { + if (!sys::fs::exists(LockFileName)) { // The previous owner released the lock file before we could read it. // Try to get ownership again. continue; @@ -149,7 +149,7 @@ LockFileManager::LockFileManager(StringRef FileName) // There is a lock file that nobody owns; try to clean it up and get // ownership. - if ((EC = sys::fs::remove(LockFileName.str()))) { + if ((EC = sys::fs::remove(LockFileName))) { Error = EC; return; } @@ -171,8 +171,8 @@ LockFileManager::~LockFileManager() { return; // Since we own the lock, remove the lock file and our own unique lock file. - sys::fs::remove(LockFileName.str()); - sys::fs::remove(UniqueLockFileName.str()); + sys::fs::remove(LockFileName); + sys::fs::remove(UniqueLockFileName); } LockFileManager::WaitForUnlockResult LockFileManager::waitForUnlock() { @@ -203,7 +203,7 @@ LockFileManager::WaitForUnlockResult LockFileManager::waitForUnlock() { if (sys::fs::access(LockFileName.c_str(), sys::fs::AccessMode::Exist) == errc::no_such_file_or_directory) { // If the original file wasn't created, somone thought the lock was dead. - if (!sys::fs::exists(FileName.str())) + if (!sys::fs::exists(FileName)) return Res_OwnerDied; return Res_Success; } @@ -236,5 +236,5 @@ LockFileManager::WaitForUnlockResult LockFileManager::waitForUnlock() { } std::error_code LockFileManager::unsafeRemoveLockFile() { - return sys::fs::remove(LockFileName.str()); + return sys::fs::remove(LockFileName); } diff --git a/llvm/lib/Support/Triple.cpp b/llvm/lib/Support/Triple.cpp index c3955714eb7..d74173a6621 100644 --- a/llvm/lib/Support/Triple.cpp +++ b/llvm/lib/Support/Triple.cpp @@ -850,7 +850,7 @@ void Triple::setArchName(StringRef Str) { Triple += getVendorName(); Triple += "-"; Triple += getOSAndEnvironmentName(); - setTriple(Triple.str()); + setTriple(Triple); } void Triple::setVendorName(StringRef Str) { diff --git a/llvm/lib/Support/Windows/Path.inc b/llvm/lib/Support/Windows/Path.inc index d8b5702bf15..d558ff5bfae 100644 --- a/llvm/lib/Support/Windows/Path.inc +++ b/llvm/lib/Support/Windows/Path.inc @@ -599,8 +599,8 @@ std::error_code detail::directory_iterator_construct(detail::DirIterState &it, it.IterationHandle = intptr_t(FindHandle.take()); SmallString<128> directory_entry_path(path); - path::append(directory_entry_path, directory_entry_name_utf8.str()); - it.CurrentEntry = directory_entry(directory_entry_path.str()); + path::append(directory_entry_path, directory_entry_name_utf8); + it.CurrentEntry = directory_entry(directory_entry_path); return std::error_code(); } diff --git a/llvm/utils/TableGen/FixedLenDecoderEmitter.cpp b/llvm/utils/TableGen/FixedLenDecoderEmitter.cpp index 292a2b17c5b..c69b89b9bc0 100644 --- a/llvm/utils/TableGen/FixedLenDecoderEmitter.cpp +++ b/llvm/utils/TableGen/FixedLenDecoderEmitter.cpp @@ -1091,7 +1091,7 @@ unsigned FilterChooser::getDecoderIndex(DecoderSet &Decoders, // overkill for now, though. // Make sure the predicate is in the table. - Decoders.insert(Decoder.str()); + Decoders.insert(StringRef(Decoder)); // Now figure out the index for when we write out the table. DecoderSet::const_iterator P = std::find(Decoders.begin(), Decoders.end(), |