summaryrefslogtreecommitdiffstats
path: root/Source/cmWhileCommand.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/cmWhileCommand.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/cmWhileCommand.cxx')
-rw-r--r--Source/cmWhileCommand.cxx122
1 files changed, 51 insertions, 71 deletions
diff --git a/Source/cmWhileCommand.cxx b/Source/cmWhileCommand.cxx
index 5fdccaa..bec2861 100644
--- a/Source/cmWhileCommand.cxx
+++ b/Source/cmWhileCommand.cxx
@@ -13,8 +13,9 @@
#include "cmConditionEvaluator.h"
-cmWhileFunctionBlocker::cmWhileFunctionBlocker(cmMakefile* mf):
- Makefile(mf), Depth(0)
+cmWhileFunctionBlocker::cmWhileFunctionBlocker(cmMakefile* mf)
+ : Makefile(mf)
+ , Depth(0)
{
this->Makefile->PushLoopBlock();
}
@@ -24,25 +25,23 @@ cmWhileFunctionBlocker::~cmWhileFunctionBlocker()
this->Makefile->PopLoopBlock();
}
-bool cmWhileFunctionBlocker::
-IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf,
- cmExecutionStatus &inStatus)
+bool cmWhileFunctionBlocker::IsFunctionBlocked(const cmListFileFunction& lff,
+ cmMakefile& mf,
+ cmExecutionStatus& inStatus)
{
// at end of for each execute recorded commands
- if (!cmSystemTools::Strucmp(lff.Name.c_str(),"while"))
- {
+ if (!cmSystemTools::Strucmp(lff.Name.c_str(), "while")) {
// record the number of while commands past this one
this->Depth++;
- }
- else if (!cmSystemTools::Strucmp(lff.Name.c_str(),"endwhile"))
- {
+ } else if (!cmSystemTools::Strucmp(lff.Name.c_str(), "endwhile")) {
// if this is the endwhile for this while loop then execute
- if (!this->Depth)
- {
+ if (!this->Depth) {
// Remove the function blocker for this scope or bail.
- cmsys::auto_ptr<cmFunctionBlocker>
- fb(mf.RemoveFunctionBlocker(this, lff));
- if(!fb.get()) { return false; }
+ cmsys::auto_ptr<cmFunctionBlocker> fb(
+ mf.RemoveFunctionBlocker(this, lff));
+ if (!fb.get()) {
+ return false;
+ }
std::string errorString;
@@ -56,74 +55,61 @@ IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf,
commandContext.Line = execContext.Line;
commandContext.Name = execContext.Name;
- cmConditionEvaluator conditionEvaluator(
- mf,
- this->GetStartingContext(),
- mf.GetBacktrace(commandContext));
+ cmConditionEvaluator conditionEvaluator(mf, this->GetStartingContext(),
+ mf.GetBacktrace(commandContext));
- bool isTrue = conditionEvaluator.IsTrue(
- expandedArguments, errorString, messageType);
+ bool isTrue =
+ conditionEvaluator.IsTrue(expandedArguments, errorString, messageType);
- while (isTrue)
- {
- if (!errorString.empty())
- {
+ while (isTrue) {
+ if (!errorString.empty()) {
std::string err = "had incorrect arguments: ";
unsigned int i;
- for(i =0; i < this->Args.size(); ++i)
- {
- err += (this->Args[i].Delim?"\"":"");
+ for (i = 0; i < this->Args.size(); ++i) {
+ err += (this->Args[i].Delim ? "\"" : "");
err += this->Args[i].Value;
- err += (this->Args[i].Delim?"\"":"");
+ err += (this->Args[i].Delim ? "\"" : "");
err += " ";
- }
+ }
err += "(";
err += errorString;
err += ").";
mf.IssueMessage(messageType, err);
- if (messageType == cmake::FATAL_ERROR)
- {
+ if (messageType == cmake::FATAL_ERROR) {
cmSystemTools::SetFatalErrorOccured();
return true;
- }
}
+ }
// Invoke all the functions that were collected in the block.
- for(unsigned int c = 0; c < this->Functions.size(); ++c)
- {
+ for (unsigned int c = 0; c < this->Functions.size(); ++c) {
cmExecutionStatus status;
- mf.ExecuteCommand(this->Functions[c],status);
- if (status.GetReturnInvoked())
- {
+ mf.ExecuteCommand(this->Functions[c], status);
+ if (status.GetReturnInvoked()) {
inStatus.SetReturnInvoked(true);
return true;
- }
- if (status.GetBreakInvoked())
- {
+ }
+ if (status.GetBreakInvoked()) {
return true;
- }
- if (status.GetContinueInvoked())
- {
+ }
+ if (status.GetContinueInvoked()) {
break;
- }
- if(cmSystemTools::GetFatalErrorOccured() )
- {
+ }
+ if (cmSystemTools::GetFatalErrorOccured()) {
return true;
- }
}
+ }
expandedArguments.clear();
mf.ExpandArguments(this->Args, expandedArguments);
- isTrue = conditionEvaluator.IsTrue(
- expandedArguments, errorString, messageType);
- }
- return true;
+ isTrue = conditionEvaluator.IsTrue(expandedArguments, errorString,
+ messageType);
}
- else
- {
+ return true;
+ } else {
// decrement for each nested while that ends
this->Depth--;
- }
}
+ }
// record the command
this->Functions.push_back(lff);
@@ -132,37 +118,31 @@ IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf,
return true;
}
-bool cmWhileFunctionBlocker::
-ShouldRemove(const cmListFileFunction& lff, cmMakefile& )
+bool cmWhileFunctionBlocker::ShouldRemove(const cmListFileFunction& lff,
+ cmMakefile&)
{
- if(!cmSystemTools::Strucmp(lff.Name.c_str(),"endwhile"))
- {
+ if (!cmSystemTools::Strucmp(lff.Name.c_str(), "endwhile")) {
// if the endwhile has arguments, then make sure
// they match the arguments of the matching while
- if (lff.Arguments.empty() ||
- lff.Arguments == this->Args)
- {
+ if (lff.Arguments.empty() || lff.Arguments == this->Args) {
return true;
- }
}
+ }
return false;
}
-bool cmWhileCommand
-::InvokeInitialPass(const std::vector<cmListFileArgument>& args,
- cmExecutionStatus &)
+bool cmWhileCommand::InvokeInitialPass(
+ const std::vector<cmListFileArgument>& args, cmExecutionStatus&)
{
- if(args.size() < 1)
- {
+ if (args.size() < 1) {
this->SetError("called with incorrect number of arguments");
return false;
- }
+ }
// create a function blocker
- cmWhileFunctionBlocker *f = new cmWhileFunctionBlocker(this->Makefile);
+ cmWhileFunctionBlocker* f = new cmWhileFunctionBlocker(this->Makefile);
f->Args = args;
this->Makefile->AddFunctionBlocker(f);
return true;
}
-