Skip to content

Commit 5b2772e

Browse files
[clangd] Use SmallString::operator std::string (NFC)
1 parent 196a71e commit 5b2772e

File tree

6 files changed

+9
-9
lines changed

6 files changed

+9
-9
lines changed

clang-tools-extra/clangd/CompileCommands.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ std::string resolve(std::string Path) {
8282
log("Failed to resolve possible symlink {0}", Path);
8383
return Path;
8484
}
85-
return std::string(Resolved.str());
85+
return std::string(Resolved);
8686
}
8787

8888
// Get a plausible full `clang` path.
@@ -114,7 +114,7 @@ std::string detectClangPath() {
114114
SmallString<128> ClangPath;
115115
ClangPath = llvm::sys::path::parent_path(ClangdExecutable);
116116
llvm::sys::path::append(ClangPath, "clang");
117-
return std::string(ClangPath.str());
117+
return std::string(ClangPath);
118118
}
119119

120120
// On mac, /usr/bin/clang sets SDKROOT and then invokes the real clang.

clang-tools-extra/clangd/Diagnostics.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -663,7 +663,7 @@ static void fillNonLocationData(DiagnosticsEngine::Level DiagLevel,
663663
llvm::SmallString<64> Message;
664664
Info.FormatDiagnostic(Message);
665665

666-
D.Message = std::string(Message.str());
666+
D.Message = std::string(Message);
667667
D.Severity = DiagLevel;
668668
D.Category = DiagnosticIDs::getCategoryNameFromID(
669669
DiagnosticIDs::getCategoryNumberForDiag(Info.getID()))
@@ -798,7 +798,7 @@ void StoreDiags::HandleDiagnostic(DiagnosticsEngine::Level DiagLevel,
798798
if (Message.empty()) // either !SyntheticMessage, or we failed to make one.
799799
Info.FormatDiagnostic(Message);
800800
LastDiag->Fixes.push_back(
801-
Fix{std::string(Message.str()), std::move(Edits), {}});
801+
Fix{std::string(Message), std::move(Edits), {}});
802802
return true;
803803
};
804804

clang-tools-extra/clangd/ExpectedTypes.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ std::optional<OpaqueType> OpaqueType::encode(ASTContext &Ctx, QualType T) {
7171
llvm::SmallString<128> Encoded;
7272
if (index::generateUSRForType(QualType(C, 0), Ctx, Encoded))
7373
return std::nullopt;
74-
return OpaqueType(std::string(Encoded.str()));
74+
return OpaqueType(std::string(Encoded));
7575
}
7676

7777
OpaqueType::OpaqueType(std::string Data) : Data(std::move(Data)) {}

clang-tools-extra/clangd/FS.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ PreambleFileStatusCache::PreambleFileStatusCache(llvm::StringRef MainFilePath){
2020
assert(llvm::sys::path::is_absolute(MainFilePath));
2121
llvm::SmallString<256> MainFileCanonical(MainFilePath);
2222
llvm::sys::path::remove_dots(MainFileCanonical, /*remove_dot_dot=*/true);
23-
this->MainFilePath = std::string(MainFileCanonical.str());
23+
this->MainFilePath = std::string(MainFileCanonical);
2424
}
2525

2626
void PreambleFileStatusCache::update(const llvm::vfs::FileSystem &FS,

clang-tools-extra/clangd/XRefs.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1619,7 +1619,7 @@ std::vector<SymbolDetails> getSymbolInfo(ParsedAST &AST, Position Pos) {
16191619
}
16201620
llvm::SmallString<32> USR;
16211621
if (!index::generateUSRForDecl(D, USR)) {
1622-
NewSymbol.USR = std::string(USR.str());
1622+
NewSymbol.USR = std::string(USR);
16231623
NewSymbol.ID = SymbolID(NewSymbol.USR);
16241624
}
16251625
if (const NamedDecl *Def = getDefinition(D))
@@ -1642,7 +1642,7 @@ std::vector<SymbolDetails> getSymbolInfo(ParsedAST &AST, Position Pos) {
16421642
llvm::SmallString<32> USR;
16431643
if (!index::generateUSRForMacro(NewMacro.name, M->Info->getDefinitionLoc(),
16441644
SM, USR)) {
1645-
NewMacro.USR = std::string(USR.str());
1645+
NewMacro.USR = std::string(USR);
16461646
NewMacro.ID = SymbolID(NewMacro.USR);
16471647
}
16481648
Results.push_back(std::move(NewMacro));

clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ std::string getShardPathFromFilePath(llvm::StringRef ShardRoot,
3030
llvm::sys::path::append(ShardRootSS, llvm::sys::path::filename(FilePath) +
3131
"." + llvm::toHex(digest(FilePath)) +
3232
".idx");
33-
return std::string(ShardRootSS.str());
33+
return std::string(ShardRootSS);
3434
}
3535

3636
// Uses disk as a storage for index shards.

0 commit comments

Comments
 (0)