summaryrefslogtreecommitdiffstats
path: root/Source/cmFunctionCommand.cxx
diff options
context:
space:
mode:
authorKitware Robot <kwrobot@kitware.com>2016-05-16 14:34:04 (GMT)
committerBrad King <brad.king@kitware.com>2016-05-16 20:05:19 (GMT)
commitd9fd2f5402eeaa345691313658e02b51038f570b (patch)
treedca71b9a7e267f4c6300da3eb770415381726785 /Source/cmFunctionCommand.cxx
parent82df6deaafb36cbbfd450202bb20b320f637751a (diff)
downloadCMake-d9fd2f5402eeaa345691313658e02b51038f570b.zip
CMake-d9fd2f5402eeaa345691313658e02b51038f570b.tar.gz
CMake-d9fd2f5402eeaa345691313658e02b51038f570b.tar.bz2
Revise C++ coding style using clang-format
Run the `Utilities/Scripts/clang-format.bash` script to update all our C++ code to a new style defined by `.clang-format`. Use `clang-format` version 3.8. * If you reached this commit for a line in `git blame`, re-run the blame operation starting at the parent of this commit to see older history for the content. * See the parent commit for instructions to rebase a change across this style transition commit.
Diffstat (limited to 'Source/cmFunctionCommand.cxx')
-rw-r--r--Source/cmFunctionCommand.cxx113
1 files changed, 45 insertions, 68 deletions
diff --git a/Source/cmFunctionCommand.cxx b/Source/cmFunctionCommand.cxx
index c883ad7..de9887e 100644
--- a/Source/cmFunctionCommand.cxx
+++ b/Source/cmFunctionCommand.cxx
@@ -28,17 +28,14 @@ public:
* cmMacroHelperCommand and cmFunctionHelperCommand
* which cannot provide appropriate documentation.
*/
- virtual bool ShouldAppearInDocumentation() const
- {
- return false;
- }
+ virtual bool ShouldAppearInDocumentation() const { return false; }
/**
* This is a virtual constructor for the command.
*/
virtual cmCommand* Clone()
{
- cmFunctionHelperCommand *newC = new cmFunctionHelperCommand;
+ cmFunctionHelperCommand* newC = new cmFunctionHelperCommand;
// we must copy when we clone
newC->Args = this->Args;
newC->Functions = this->Functions;
@@ -57,10 +54,12 @@ public:
* the CMakeLists.txt file.
*/
virtual bool InvokeInitialPass(const std::vector<cmListFileArgument>& args,
- cmExecutionStatus &);
+ cmExecutionStatus&);
- virtual bool InitialPass(std::vector<std::string> const&,
- cmExecutionStatus &) { return false; }
+ virtual bool InitialPass(std::vector<std::string> const&, cmExecutionStatus&)
+ {
+ return false;
+ }
/**
* The name of the command as specified in CMakeList.txt.
@@ -75,9 +74,8 @@ public:
std::string FilePath;
};
-bool cmFunctionHelperCommand::InvokeInitialPass
-(const std::vector<cmListFileArgument>& args,
- cmExecutionStatus & inStatus)
+bool cmFunctionHelperCommand::InvokeInitialPass(
+ const std::vector<cmListFileArgument>& args, cmExecutionStatus& inStatus)
{
// Expand the argument list to the function.
std::vector<std::string> expandedArgs;
@@ -85,46 +83,40 @@ bool cmFunctionHelperCommand::InvokeInitialPass
// make sure the number of arguments passed is at least the number
// required by the signature
- if (expandedArgs.size() < this->Args.size() - 1)
- {
+ if (expandedArgs.size() < this->Args.size() - 1) {
std::string errorMsg =
"Function invoked with incorrect arguments for function named: ";
errorMsg += this->Args[0];
this->SetError(errorMsg);
return false;
- }
+ }
- cmMakefile::FunctionPushPop functionScope(this->Makefile,
- this->FilePath,
+ cmMakefile::FunctionPushPop functionScope(this->Makefile, this->FilePath,
this->Policies);
// set the value of argc
std::ostringstream strStream;
strStream << expandedArgs.size();
- this->Makefile->AddDefinition("ARGC",strStream.str().c_str());
+ this->Makefile->AddDefinition("ARGC", strStream.str().c_str());
this->Makefile->MarkVariableAsUsed("ARGC");
// set the values for ARGV0 ARGV1 ...
- for (unsigned int t = 0; t < expandedArgs.size(); ++t)
- {
+ for (unsigned int t = 0; t < expandedArgs.size(); ++t) {
std::ostringstream tmpStream;
tmpStream << "ARGV" << t;
- this->Makefile->AddDefinition(tmpStream.str(),
- expandedArgs[t].c_str());
+ this->Makefile->AddDefinition(tmpStream.str(), expandedArgs[t].c_str());
this->Makefile->MarkVariableAsUsed(tmpStream.str());
- }
+ }
// define the formal arguments
- for (unsigned int j = 1; j < this->Args.size(); ++j)
- {
- this->Makefile->AddDefinition(this->Args[j],
- expandedArgs[j-1].c_str());
- }
+ for (unsigned int j = 1; j < this->Args.size(); ++j) {
+ this->Makefile->AddDefinition(this->Args[j], expandedArgs[j - 1].c_str());
+ }
// define ARGV and ARGN
std::string argvDef = cmJoin(expandedArgs, ";");
- std::vector<std::string>::const_iterator eit
- = expandedArgs.begin() + (this->Args.size()-1);
+ std::vector<std::string>::const_iterator eit =
+ expandedArgs.begin() + (this->Args.size() - 1);
std::string argnDef = cmJoin(cmMakeRange(eit, expandedArgs.end()), ";");
this->Makefile->AddDefinition("ARGV", argvDef.c_str());
this->Makefile->MarkVariableAsUsed("ARGV");
@@ -133,45 +125,37 @@ bool cmFunctionHelperCommand::InvokeInitialPass
// Invoke all the functions that were collected in the block.
// for each function
- for(unsigned int c = 0; c < this->Functions.size(); ++c)
- {
+ for (unsigned int c = 0; c < this->Functions.size(); ++c) {
cmExecutionStatus status;
- if (!this->Makefile->ExecuteCommand(this->Functions[c],status) ||
- status.GetNestedError())
- {
+ if (!this->Makefile->ExecuteCommand(this->Functions[c], status) ||
+ status.GetNestedError()) {
// The error message should have already included the call stack
// so we do not need to report an error here.
functionScope.Quiet();
inStatus.SetNestedError(true);
return false;
- }
- if (status.GetReturnInvoked())
- {
+ }
+ if (status.GetReturnInvoked()) {
return true;
- }
}
+ }
// pop scope on the makefile
return true;
}
-bool cmFunctionFunctionBlocker::
-IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf,
- cmExecutionStatus &)
+bool cmFunctionFunctionBlocker::IsFunctionBlocked(
+ const cmListFileFunction& lff, cmMakefile& mf, cmExecutionStatus&)
{
// record commands until we hit the ENDFUNCTION
// at the ENDFUNCTION call we shift gears and start looking for invocations
- if(!cmSystemTools::Strucmp(lff.Name.c_str(),"function"))
- {
+ if (!cmSystemTools::Strucmp(lff.Name.c_str(), "function")) {
this->Depth++;
- }
- else if(!cmSystemTools::Strucmp(lff.Name.c_str(),"endfunction"))
- {
+ } else if (!cmSystemTools::Strucmp(lff.Name.c_str(), "endfunction")) {
// if this is the endfunction for this function then execute
- if (!this->Depth)
- {
+ if (!this->Depth) {
// create a new command and add it to cmake
- cmFunctionHelperCommand *f = new cmFunctionHelperCommand();
+ cmFunctionHelperCommand* f = new cmFunctionHelperCommand();
f->Args = this->Args;
f->Functions = this->Functions;
f->FilePath = this->GetStartingContext().FilePath;
@@ -184,13 +168,11 @@ IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf,
// remove the function blocker now that the function is defined
mf.RemoveFunctionBlocker(this, lff);
return true;
- }
- else
- {
+ } else {
// decrement for each nested function that ends
this->Depth--;
- }
}
+ }
// if it wasn't an endfunction and we are not executing then we must be
// recording
@@ -198,40 +180,35 @@ IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf,
return true;
}
-
-bool cmFunctionFunctionBlocker::
-ShouldRemove(const cmListFileFunction& lff, cmMakefile &mf)
+bool cmFunctionFunctionBlocker::ShouldRemove(const cmListFileFunction& lff,
+ cmMakefile& mf)
{
- if(!cmSystemTools::Strucmp(lff.Name.c_str(),"endfunction"))
- {
+ if (!cmSystemTools::Strucmp(lff.Name.c_str(), "endfunction")) {
std::vector<std::string> expandedArguments;
mf.ExpandArguments(lff.Arguments, expandedArguments,
this->GetStartingContext().FilePath.c_str());
// if the endfunction has arguments then make sure
// they match the ones in the opening function command
if ((expandedArguments.empty() ||
- (expandedArguments[0] == this->Args[0])))
- {
+ (expandedArguments[0] == this->Args[0]))) {
return true;
- }
}
+ }
return false;
}
-bool cmFunctionCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmFunctionCommand::InitialPass(std::vector<std::string> const& args,
+ cmExecutionStatus&)
{
- if(args.size() < 1)
- {
+ if (args.size() < 1) {
this->SetError("called with incorrect number of arguments");
return false;
- }
+ }
// create a function blocker
- cmFunctionFunctionBlocker *f = new cmFunctionFunctionBlocker();
+ cmFunctionFunctionBlocker* f = new cmFunctionFunctionBlocker();
f->Args.insert(f->Args.end(), args.begin(), args.end());
this->Makefile->AddFunctionBlocker(f);
return true;
}
-