[clang-tools-extra] 2b00d44 - [clang-tools-extra] Use SmallString::operator std::string (NFC)

Kazu Hirata via cfe-commits cfe-commits at lists.llvm.org
Fri Jan 26 23:46:35 PST 2024


Author: Kazu Hirata
Date: 2024-01-26T23:46:24-08:00
New Revision: 2b00d449d2ed09cd0364038115f90a3eb4fd15b5

URL: https://github.com/llvm/llvm-project/commit/2b00d449d2ed09cd0364038115f90a3eb4fd15b5
DIFF: https://github.com/llvm/llvm-project/commit/2b00d449d2ed09cd0364038115f90a3eb4fd15b5.diff

LOG: [clang-tools-extra] Use SmallString::operator std::string (NFC)

Added: 
    

Modified: 
    clang-tools-extra/clang-doc/HTMLGenerator.cpp
    clang-tools-extra/clang-doc/Representation.cpp
    clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
    clang-tools-extra/clang-include-fixer/find-all-symbols/PathConfig.cpp
    clang-tools-extra/clang-move/Move.cpp
    clang-tools-extra/clang-move/tool/ClangMove.cpp
    clang-tools-extra/clang-tidy/utils/HeaderGuard.cpp
    clang-tools-extra/modularize/ModularizeUtilities.cpp

Removed: 
    


################################################################################
diff  --git a/clang-tools-extra/clang-doc/HTMLGenerator.cpp b/clang-tools-extra/clang-doc/HTMLGenerator.cpp
index f6355ccf4f844e..c0faf5f7e8fd9b 100644
--- a/clang-tools-extra/clang-doc/HTMLGenerator.cpp
+++ b/clang-tools-extra/clang-doc/HTMLGenerator.cpp
@@ -280,7 +280,7 @@ genStylesheetsHTML(StringRef InfoPath, const ClangDocContext &CDCtx) {
                             llvm::sys::path::filename(FilePath));
     // Paths in HTML must be in posix-style
     llvm::sys::path::native(StylesheetPath, llvm::sys::path::Style::posix);
-    LinkNode->Attributes.emplace_back("href", std::string(StylesheetPath.str()));
+    LinkNode->Attributes.emplace_back("href", std::string(StylesheetPath));
     Out.emplace_back(std::move(LinkNode));
   }
   return Out;
@@ -295,7 +295,7 @@ genJsScriptsHTML(StringRef InfoPath, const ClangDocContext &CDCtx) {
     llvm::sys::path::append(ScriptPath, llvm::sys::path::filename(FilePath));
     // Paths in HTML must be in posix-style
     llvm::sys::path::native(ScriptPath, llvm::sys::path::Style::posix);
-    ScriptNode->Attributes.emplace_back("src", std::string(ScriptPath.str()));
+    ScriptNode->Attributes.emplace_back("src", std::string(ScriptPath));
     Out.emplace_back(std::move(ScriptNode));
   }
   return Out;

diff  --git a/clang-tools-extra/clang-doc/Representation.cpp b/clang-tools-extra/clang-doc/Representation.cpp
index 7dcf646322e6f6..84233c36e15d98 100644
--- a/clang-tools-extra/clang-doc/Representation.cpp
+++ b/clang-tools-extra/clang-doc/Representation.cpp
@@ -377,7 +377,7 @@ ClangDocContext::ClangDocContext(tooling::ExecutionContext *ECtx,
   if (SourceRoot.empty())
     // If no SourceRoot was provided the current path is used as the default
     llvm::sys::fs::current_path(SourceRootDir);
-  this->SourceRoot = std::string(SourceRootDir.str());
+  this->SourceRoot = std::string(SourceRootDir);
   if (!RepositoryUrl.empty()) {
     this->RepositoryUrl = std::string(RepositoryUrl);
     if (!RepositoryUrl.empty() && RepositoryUrl.find("http://") != 0 &&

diff  --git a/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp b/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
index 2ece3e4c071dc0..22bdb5de22d871 100644
--- a/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
+++ b/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
@@ -197,7 +197,7 @@ Example usage for a project using a compile commands database:
     llvm::sys::path::native(AssetsPath, IndexJS);
     llvm::sys::path::append(IndexJS, "index.js");
     CDCtx.UserStylesheets.insert(CDCtx.UserStylesheets.begin(),
-                                 std::string(DefaultStylesheet.str()));
+                                 std::string(DefaultStylesheet));
     CDCtx.FilesToCopy.emplace_back(IndexJS.str());
   }
 

diff  --git a/clang-tools-extra/clang-include-fixer/find-all-symbols/PathConfig.cpp b/clang-tools-extra/clang-include-fixer/find-all-symbols/PathConfig.cpp
index 6d52963370ddd7..c3f8000f3a1f2a 100644
--- a/clang-tools-extra/clang-include-fixer/find-all-symbols/PathConfig.cpp
+++ b/clang-tools-extra/clang-include-fixer/find-all-symbols/PathConfig.cpp
@@ -35,7 +35,7 @@ std::string getIncludePath(const SourceManager &SM, SourceLocation Loc,
   SmallString<256> CleanedFilePath = FilePath;
   llvm::sys::path::remove_dots(CleanedFilePath, /*remove_dot_dot=*/false);
 
-  return std::string(CleanedFilePath.str());
+  return std::string(CleanedFilePath);
 }
 
 } // namespace find_all_symbols

diff  --git a/clang-tools-extra/clang-move/Move.cpp b/clang-tools-extra/clang-move/Move.cpp
index 404acf55e3aa53..1d10348430c281 100644
--- a/clang-tools-extra/clang-move/Move.cpp
+++ b/clang-tools-extra/clang-move/Move.cpp
@@ -65,7 +65,7 @@ std::string CleanPath(StringRef PathRef) {
   llvm::sys::path::remove_dots(Path, /*remove_dot_dot=*/true);
   // FIXME: figure out why this is necessary.
   llvm::sys::path::native(Path);
-  return std::string(Path.str());
+  return std::string(Path);
 }
 
 // Make the Path absolute using the CurrentDir if the Path is not an absolute

diff  --git a/clang-tools-extra/clang-move/tool/ClangMove.cpp b/clang-tools-extra/clang-move/tool/ClangMove.cpp
index a38538768226ed..1560dcaad67793 100644
--- a/clang-tools-extra/clang-move/tool/ClangMove.cpp
+++ b/clang-tools-extra/clang-move/tool/ClangMove.cpp
@@ -131,7 +131,7 @@ int main(int argc, const char **argv) {
                              Twine(EC.message()));
 
   move::ClangMoveContext Context{Spec, Tool.getReplacements(),
-                                 std::string(InitialDirectory.str()), Style,
+                                 std::string(InitialDirectory), Style,
                                  DumpDecls};
   move::DeclarationReporter Reporter;
   move::ClangMoveActionFactory Factory(&Context, &Reporter);

diff  --git a/clang-tools-extra/clang-tidy/utils/HeaderGuard.cpp b/clang-tools-extra/clang-tidy/utils/HeaderGuard.cpp
index 3540c496515bed..0625eb38c8cdf6 100644
--- a/clang-tools-extra/clang-tidy/utils/HeaderGuard.cpp
+++ b/clang-tools-extra/clang-tidy/utils/HeaderGuard.cpp
@@ -19,7 +19,7 @@ namespace clang::tidy::utils {
 static std::string cleanPath(StringRef Path) {
   SmallString<256> Result = Path;
   llvm::sys::path::remove_dots(Result, true);
-  return std::string(Result.str());
+  return std::string(Result);
 }
 
 namespace {

diff  --git a/clang-tools-extra/modularize/ModularizeUtilities.cpp b/clang-tools-extra/modularize/ModularizeUtilities.cpp
index d25bb09b8cad5b..53e8a49d1a5489 100644
--- a/clang-tools-extra/modularize/ModularizeUtilities.cpp
+++ b/clang-tools-extra/modularize/ModularizeUtilities.cpp
@@ -487,7 +487,7 @@ std::string ModularizeUtilities::getDirectoryFromPath(StringRef Path) {
   sys::path::remove_filename(Directory);
   if (Directory.size() == 0)
     return ".";
-  return std::string(Directory.str());
+  return std::string(Directory);
 }
 
 // Add unique problem file.


        


More information about the cfe-commits mailing list