Skip to content

Commit

Permalink
[clang-tools-extra] Use SmallString::operator std::string (NFC)
Browse files Browse the repository at this point in the history
  • Loading branch information
kazutakahirata committed Jan 27, 2024
1 parent 6e6c506 commit 2b00d44
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions clang-tools-extra/clang-doc/HTMLGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion clang-tools-extra/clang-doc/Representation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 &&
Expand Down
2 changes: 1 addition & 1 deletion clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion clang-tools-extra/clang-move/Move.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion clang-tools-extra/clang-move/tool/ClangMove.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion clang-tools-extra/clang-tidy/utils/HeaderGuard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion clang-tools-extra/modularize/ModularizeUtilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 2b00d44

Please sign in to comment.