[clang-tools-extra] 5b2772e - [clangd] Use SmallString::operator std::string (NFC)
Kazu Hirata via cfe-commits
cfe-commits at lists.llvm.org
Wed Jan 24 22:12:06 PST 2024
Author: Kazu Hirata
Date: 2024-01-24T22:11:54-08:00
New Revision: 5b2772e1fad3fc8b44400b91de4d5bd0724bba75
URL: https://github.com/llvm/llvm-project/commit/5b2772e1fad3fc8b44400b91de4d5bd0724bba75
DIFF: https://github.com/llvm/llvm-project/commit/5b2772e1fad3fc8b44400b91de4d5bd0724bba75.diff
LOG: [clangd] Use SmallString::operator std::string (NFC)
Added:
Modified:
clang-tools-extra/clangd/CompileCommands.cpp
clang-tools-extra/clangd/Diagnostics.cpp
clang-tools-extra/clangd/ExpectedTypes.cpp
clang-tools-extra/clangd/FS.cpp
clang-tools-extra/clangd/XRefs.cpp
clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp
Removed:
################################################################################
diff --git a/clang-tools-extra/clangd/CompileCommands.cpp b/clang-tools-extra/clangd/CompileCommands.cpp
index 166f17e9b3f7125..5b8128fca62668c 100644
--- a/clang-tools-extra/clangd/CompileCommands.cpp
+++ b/clang-tools-extra/clangd/CompileCommands.cpp
@@ -82,7 +82,7 @@ std::string resolve(std::string Path) {
log("Failed to resolve possible symlink {0}", Path);
return Path;
}
- return std::string(Resolved.str());
+ return std::string(Resolved);
}
// Get a plausible full `clang` path.
@@ -114,7 +114,7 @@ std::string detectClangPath() {
SmallString<128> ClangPath;
ClangPath = llvm::sys::path::parent_path(ClangdExecutable);
llvm::sys::path::append(ClangPath, "clang");
- return std::string(ClangPath.str());
+ return std::string(ClangPath);
}
// On mac, /usr/bin/clang sets SDKROOT and then invokes the real clang.
diff --git a/clang-tools-extra/clangd/Diagnostics.cpp b/clang-tools-extra/clangd/Diagnostics.cpp
index 704e61b1e4dd792..d5eca083eb65120 100644
--- a/clang-tools-extra/clangd/Diagnostics.cpp
+++ b/clang-tools-extra/clangd/Diagnostics.cpp
@@ -663,7 +663,7 @@ static void fillNonLocationData(DiagnosticsEngine::Level DiagLevel,
llvm::SmallString<64> Message;
Info.FormatDiagnostic(Message);
- D.Message = std::string(Message.str());
+ D.Message = std::string(Message);
D.Severity = DiagLevel;
D.Category = DiagnosticIDs::getCategoryNameFromID(
DiagnosticIDs::getCategoryNumberForDiag(Info.getID()))
@@ -798,7 +798,7 @@ void StoreDiags::HandleDiagnostic(DiagnosticsEngine::Level DiagLevel,
if (Message.empty()) // either !SyntheticMessage, or we failed to make one.
Info.FormatDiagnostic(Message);
LastDiag->Fixes.push_back(
- Fix{std::string(Message.str()), std::move(Edits), {}});
+ Fix{std::string(Message), std::move(Edits), {}});
return true;
};
diff --git a/clang-tools-extra/clangd/ExpectedTypes.cpp b/clang-tools-extra/clangd/ExpectedTypes.cpp
index deea8a50111e6dc..eaa87096d0d0ef7 100644
--- a/clang-tools-extra/clangd/ExpectedTypes.cpp
+++ b/clang-tools-extra/clangd/ExpectedTypes.cpp
@@ -71,7 +71,7 @@ std::optional<OpaqueType> OpaqueType::encode(ASTContext &Ctx, QualType T) {
llvm::SmallString<128> Encoded;
if (index::generateUSRForType(QualType(C, 0), Ctx, Encoded))
return std::nullopt;
- return OpaqueType(std::string(Encoded.str()));
+ return OpaqueType(std::string(Encoded));
}
OpaqueType::OpaqueType(std::string Data) : Data(std::move(Data)) {}
diff --git a/clang-tools-extra/clangd/FS.cpp b/clang-tools-extra/clangd/FS.cpp
index c67636dbf2d4ad6..5729b9341d9d4b9 100644
--- a/clang-tools-extra/clangd/FS.cpp
+++ b/clang-tools-extra/clangd/FS.cpp
@@ -20,7 +20,7 @@ PreambleFileStatusCache::PreambleFileStatusCache(llvm::StringRef MainFilePath){
assert(llvm::sys::path::is_absolute(MainFilePath));
llvm::SmallString<256> MainFileCanonical(MainFilePath);
llvm::sys::path::remove_dots(MainFileCanonical, /*remove_dot_dot=*/true);
- this->MainFilePath = std::string(MainFileCanonical.str());
+ this->MainFilePath = std::string(MainFileCanonical);
}
void PreambleFileStatusCache::update(const llvm::vfs::FileSystem &FS,
diff --git a/clang-tools-extra/clangd/XRefs.cpp b/clang-tools-extra/clangd/XRefs.cpp
index 250d571eea191c7..cd909266489a850 100644
--- a/clang-tools-extra/clangd/XRefs.cpp
+++ b/clang-tools-extra/clangd/XRefs.cpp
@@ -1619,7 +1619,7 @@ std::vector<SymbolDetails> getSymbolInfo(ParsedAST &AST, Position Pos) {
}
llvm::SmallString<32> USR;
if (!index::generateUSRForDecl(D, USR)) {
- NewSymbol.USR = std::string(USR.str());
+ NewSymbol.USR = std::string(USR);
NewSymbol.ID = SymbolID(NewSymbol.USR);
}
if (const NamedDecl *Def = getDefinition(D))
@@ -1642,7 +1642,7 @@ std::vector<SymbolDetails> getSymbolInfo(ParsedAST &AST, Position Pos) {
llvm::SmallString<32> USR;
if (!index::generateUSRForMacro(NewMacro.name, M->Info->getDefinitionLoc(),
SM, USR)) {
- NewMacro.USR = std::string(USR.str());
+ NewMacro.USR = std::string(USR);
NewMacro.ID = SymbolID(NewMacro.USR);
}
Results.push_back(std::move(NewMacro));
diff --git a/clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp b/clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp
index e32ddd052e41881..d887b09482a9597 100644
--- a/clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp
+++ b/clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp
@@ -30,7 +30,7 @@ std::string getShardPathFromFilePath(llvm::StringRef ShardRoot,
llvm::sys::path::append(ShardRootSS, llvm::sys::path::filename(FilePath) +
"." + llvm::toHex(digest(FilePath)) +
".idx");
- return std::string(ShardRootSS.str());
+ return std::string(ShardRootSS);
}
// Uses disk as a storage for index shards.
More information about the cfe-commits
mailing list