[clang] 236129f - [CompilationDatabase] Pass Twine by const reference instead of by value. NFCI.
Simon Pilgrim via cfe-commits
cfe-commits at lists.llvm.org
Thu Jan 7 04:53:44 PST 2021
Author: Simon Pilgrim
Date: 2021-01-07T12:53:28Z
New Revision: 236129fb4460a4030eee685abc2f02b32458e775
URL: https://github.com/llvm/llvm-project/commit/236129fb4460a4030eee685abc2f02b32458e775
DIFF: https://github.com/llvm/llvm-project/commit/236129fb4460a4030eee685abc2f02b32458e775.diff
LOG: [CompilationDatabase] Pass Twine by const reference instead of by value. NFCI.
Added:
Modified:
clang/include/clang/Tooling/CompilationDatabase.h
clang/lib/Tooling/CompilationDatabase.cpp
Removed:
################################################################################
diff --git a/clang/include/clang/Tooling/CompilationDatabase.h b/clang/include/clang/Tooling/CompilationDatabase.h
index cbd57e9609aa..44af236347b3 100644
--- a/clang/include/clang/Tooling/CompilationDatabase.h
+++ b/clang/include/clang/Tooling/CompilationDatabase.h
@@ -43,10 +43,10 @@ namespace tooling {
/// Specifies the working directory and command of a compilation.
struct CompileCommand {
CompileCommand() = default;
- CompileCommand(Twine Directory, Twine Filename,
- std::vector<std::string> CommandLine, Twine Output)
+ CompileCommand(const Twine &Directory, const Twine &Filename,
+ std::vector<std::string> CommandLine, const Twine &Output)
: Directory(Directory.str()), Filename(Filename.str()),
- CommandLine(std::move(CommandLine)), Output(Output.str()){}
+ CommandLine(std::move(CommandLine)), Output(Output.str()) {}
/// The working directory the command was executed from.
std::string Directory;
@@ -180,9 +180,9 @@ class FixedCompilationDatabase : public CompilationDatabase {
/// \param Argv Points to the command line arguments.
/// \param ErrorMsg Contains error text if the function returns null pointer.
/// \param Directory The base directory used in the FixedCompilationDatabase.
- static std::unique_ptr<FixedCompilationDatabase> loadFromCommandLine(
- int &Argc, const char *const *Argv, std::string &ErrorMsg,
- Twine Directory = ".");
+ static std::unique_ptr<FixedCompilationDatabase>
+ loadFromCommandLine(int &Argc, const char *const *Argv, std::string &ErrorMsg,
+ const Twine &Directory = ".");
/// Reads flags from the given file, one-per-line.
/// Returns nullptr and sets ErrorMessage if we can't read the file.
@@ -196,7 +196,8 @@ class FixedCompilationDatabase : public CompilationDatabase {
/// Constructs a compilation data base from a specified directory
/// and command line.
- FixedCompilationDatabase(Twine Directory, ArrayRef<std::string> CommandLine);
+ FixedCompilationDatabase(const Twine &Directory,
+ ArrayRef<std::string> CommandLine);
/// Returns the given compile command.
///
diff --git a/clang/lib/Tooling/CompilationDatabase.cpp b/clang/lib/Tooling/CompilationDatabase.cpp
index d339fd044c02..1e19e68633d2 100644
--- a/clang/lib/Tooling/CompilationDatabase.cpp
+++ b/clang/lib/Tooling/CompilationDatabase.cpp
@@ -323,7 +323,7 @@ std::unique_ptr<FixedCompilationDatabase>
FixedCompilationDatabase::loadFromCommandLine(int &Argc,
const char *const *Argv,
std::string &ErrorMsg,
- Twine Directory) {
+ const Twine &Directory) {
ErrorMsg.clear();
if (Argc == 0)
return nullptr;
@@ -368,8 +368,8 @@ FixedCompilationDatabase::loadFromBuffer(StringRef Directory, StringRef Data,
return std::make_unique<FixedCompilationDatabase>(Directory, std::move(Args));
}
-FixedCompilationDatabase::
-FixedCompilationDatabase(Twine Directory, ArrayRef<std::string> CommandLine) {
+FixedCompilationDatabase::FixedCompilationDatabase(
+ const Twine &Directory, ArrayRef<std::string> CommandLine) {
std::vector<std::string> ToolCommandLine(1, GetClangToolCommand());
ToolCommandLine.insert(ToolCommandLine.end(),
CommandLine.begin(), CommandLine.end());
More information about the cfe-commits
mailing list