cmMakefile: Simplify ExpandArguments signature

The only call sites that pass the explicit file name argument are in
function blocker `ArgumentsMatch` methods for `function` and `macro`.
We already ensure that they are balanced within a file scope, and the
RAII helpers `BuildsystemFileScope` and `ListFileScope` ensure that the
backtrace and execution list file stacks unwind to the matching level.
Therefore we can assume that the file name where we are checking for
matching arguments matches starting file name where those arguments
first appeared, and do not need to pass it explicitly.
This commit is contained in:
Brad King
2020-09-25 10:12:20 -04:00
parent e456dae669
commit 727ed0c403
4 changed files with 12 additions and 24 deletions
+1 -2
View File
@@ -147,8 +147,7 @@ bool cmFunctionFunctionBlocker::ArgumentsMatch(cmListFileFunction const& lff,
cmMakefile& mf) const cmMakefile& mf) const
{ {
std::vector<std::string> expandedArguments; std::vector<std::string> expandedArguments;
mf.ExpandArguments(lff.Arguments, expandedArguments, mf.ExpandArguments(lff.Arguments, expandedArguments);
this->GetStartingContext().FilePath.c_str());
return expandedArguments.empty() || return expandedArguments.empty() ||
expandedArguments.front() == this->Args.front(); expandedArguments.front() == this->Args.front();
} }
+1 -2
View File
@@ -157,8 +157,7 @@ bool cmMacroFunctionBlocker::ArgumentsMatch(cmListFileFunction const& lff,
cmMakefile& mf) const cmMakefile& mf) const
{ {
std::vector<std::string> expandedArguments; std::vector<std::string> expandedArguments;
mf.ExpandArguments(lff.Arguments, expandedArguments, mf.ExpandArguments(lff.Arguments, expandedArguments);
this->GetStartingContext().FilePath.c_str());
return expandedArguments.empty() || expandedArguments[0] == this->Args[0]; return expandedArguments.empty() || expandedArguments[0] == this->Args[0];
} }
+8 -15
View File
@@ -3335,13 +3335,9 @@ std::string const& cmMakefile::GetExecutionFilePath() const
} }
bool cmMakefile::ExpandArguments(std::vector<cmListFileArgument> const& inArgs, bool cmMakefile::ExpandArguments(std::vector<cmListFileArgument> const& inArgs,
std::vector<std::string>& outArgs, std::vector<std::string>& outArgs) const
const char* filename) const
{ {
if (!filename) { std::string const& filename = this->GetExecutionFilePath();
auto const& efp = this->GetExecutionFilePath();
filename = efp.c_str();
}
std::string value; std::string value;
outArgs.reserve(inArgs.size()); outArgs.reserve(inArgs.size());
for (cmListFileArgument const& i : inArgs) { for (cmListFileArgument const& i : inArgs) {
@@ -3352,8 +3348,8 @@ bool cmMakefile::ExpandArguments(std::vector<cmListFileArgument> const& inArgs,
} }
// Expand the variables in the argument. // Expand the variables in the argument.
value = i.Value; value = i.Value;
this->ExpandVariablesInString(value, false, false, false, filename, i.Line, this->ExpandVariablesInString(value, false, false, false, filename.c_str(),
false, false); i.Line, false, false);
// If the argument is quoted, it should be one argument. // If the argument is quoted, it should be one argument.
// Otherwise, it may be a list of arguments. // Otherwise, it may be a list of arguments.
@@ -3368,12 +3364,9 @@ bool cmMakefile::ExpandArguments(std::vector<cmListFileArgument> const& inArgs,
bool cmMakefile::ExpandArguments( bool cmMakefile::ExpandArguments(
std::vector<cmListFileArgument> const& inArgs, std::vector<cmListFileArgument> const& inArgs,
std::vector<cmExpandedCommandArgument>& outArgs, const char* filename) const std::vector<cmExpandedCommandArgument>& outArgs) const
{ {
if (!filename) { std::string const& filename = this->GetExecutionFilePath();
auto const& efp = this->GetExecutionFilePath();
filename = efp.c_str();
}
std::string value; std::string value;
outArgs.reserve(inArgs.size()); outArgs.reserve(inArgs.size());
for (cmListFileArgument const& i : inArgs) { for (cmListFileArgument const& i : inArgs) {
@@ -3384,8 +3377,8 @@ bool cmMakefile::ExpandArguments(
} }
// Expand the variables in the argument. // Expand the variables in the argument.
value = i.Value; value = i.Value;
this->ExpandVariablesInString(value, false, false, false, filename, i.Line, this->ExpandVariablesInString(value, false, false, false, filename.c_str(),
false, false); i.Line, false, false);
// If the argument is quoted, it should be one argument. // If the argument is quoted, it should be one argument.
// Otherwise, it may be a list of arguments. // Otherwise, it may be a list of arguments.
+2 -5
View File
@@ -732,12 +732,9 @@ public:
* variable replacement and list expansion. * variable replacement and list expansion.
*/ */
bool ExpandArguments(std::vector<cmListFileArgument> const& inArgs, bool ExpandArguments(std::vector<cmListFileArgument> const& inArgs,
std::vector<std::string>& outArgs, std::vector<std::string>& outArgs) const;
const char* filename = nullptr) const;
bool ExpandArguments(std::vector<cmListFileArgument> const& inArgs, bool ExpandArguments(std::vector<cmListFileArgument> const& inArgs,
std::vector<cmExpandedCommandArgument>& outArgs, std::vector<cmExpandedCommandArgument>& outArgs) const;
const char* filename = nullptr) const;
/** /**
* Get the instance * Get the instance