[clang] 8cc9fa6 - Use static_cast from SmallString to std::string (NFC)

Kazu Hirata via cfe-commits cfe-commits at lists.llvm.org
Sat Jun 4 22:09:37 PDT 2022


Author: Kazu Hirata
Date: 2022-06-04T22:09:27-07:00
New Revision: 8cc9fa6f78237a5771a5f85eb9ef129ea85a54cf

URL: https://github.com/llvm/llvm-project/commit/8cc9fa6f78237a5771a5f85eb9ef129ea85a54cf
DIFF: https://github.com/llvm/llvm-project/commit/8cc9fa6f78237a5771a5f85eb9ef129ea85a54cf.diff

LOG: Use static_cast from SmallString to std::string (NFC)

Added: 
    

Modified: 
    clang/lib/Driver/Driver.cpp
    clang/tools/libclang/CIndexer.cpp
    lldb/source/Utility/FileSpec.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 3185ebcd46a4e..8e698a2a7cbef 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -973,7 +973,7 @@ bool Driver::loadConfigFile() {
         if (llvm::sys::fs::make_absolute(CfgDir).value() != 0)
           SystemConfigDir.clear();
         else
-          SystemConfigDir = std::string(CfgDir.begin(), CfgDir.end());
+          SystemConfigDir = static_cast<std::string>(CfgDir);
       }
     }
     if (CLOptions->hasArg(options::OPT_config_user_dir_EQ)) {
@@ -984,7 +984,7 @@ bool Driver::loadConfigFile() {
         if (llvm::sys::fs::make_absolute(CfgDir).value() != 0)
           UserConfigDir.clear();
         else
-          UserConfigDir = std::string(CfgDir.begin(), CfgDir.end());
+          UserConfigDir = static_cast<std::string>(CfgDir);
       }
     }
   }

diff  --git a/clang/tools/libclang/CIndexer.cpp b/clang/tools/libclang/CIndexer.cpp
index dab3fc4e201d0..77da2e4fa5ead 100644
--- a/clang/tools/libclang/CIndexer.cpp
+++ b/clang/tools/libclang/CIndexer.cpp
@@ -176,7 +176,7 @@ LibclangInvocationReporter::LibclangInvocationReporter(
   if (llvm::sys::fs::createUniqueFile(TempPath, FD, TempPath,
                                       llvm::sys::fs::OF_Text))
     return;
-  File = std::string(TempPath.begin(), TempPath.end());
+  File = static_cast<std::string>(TempPath);
   llvm::raw_fd_ostream OS(FD, /*ShouldClose=*/true);
 
   // Write out the information about the invocation to it.

diff  --git a/lldb/source/Utility/FileSpec.cpp b/lldb/source/Utility/FileSpec.cpp
index eed3bbd46026f..c0dbc29bcd1f1 100644
--- a/lldb/source/Utility/FileSpec.cpp
+++ b/lldb/source/Utility/FileSpec.cpp
@@ -357,7 +357,7 @@ size_t FileSpec::GetPath(char *path, size_t path_max_len,
 std::string FileSpec::GetPath(bool denormalize) const {
   llvm::SmallString<64> result;
   GetPath(result, denormalize);
-  return std::string(result.begin(), result.end());
+  return static_cast<std::string>(result);
 }
 
 const char *FileSpec::GetCString(bool denormalize) const {


        


More information about the cfe-commits mailing list