diff options
author | Kitware Robot <kwrobot@kitware.com> | 2016-05-16 14:34:04 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2016-05-16 20:05:19 (GMT) |
commit | d9fd2f5402eeaa345691313658e02b51038f570b (patch) | |
tree | dca71b9a7e267f4c6300da3eb770415381726785 /Source/cmGeneratorExpressionEvaluationFile.cxx | |
parent | 82df6deaafb36cbbfd450202bb20b320f637751a (diff) | |
download | CMake-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/cmGeneratorExpressionEvaluationFile.cxx')
-rw-r--r-- | Source/cmGeneratorExpressionEvaluationFile.cxx | 150 |
1 files changed, 65 insertions, 85 deletions
diff --git a/Source/cmGeneratorExpressionEvaluationFile.cxx b/Source/cmGeneratorExpressionEvaluationFile.cxx index 75ddd28..c69e362 100644 --- a/Source/cmGeneratorExpressionEvaluationFile.cxx +++ b/Source/cmGeneratorExpressionEvaluationFile.cxx @@ -22,67 +22,59 @@ #include <assert.h> cmGeneratorExpressionEvaluationFile::cmGeneratorExpressionEvaluationFile( - const std::string &input, - cmsys::auto_ptr<cmCompiledGeneratorExpression> outputFileExpr, - cmsys::auto_ptr<cmCompiledGeneratorExpression> condition, - bool inputIsContent) - : Input(input), - OutputFileExpr(outputFileExpr), - Condition(condition), - InputIsContent(inputIsContent) + const std::string& input, + cmsys::auto_ptr<cmCompiledGeneratorExpression> outputFileExpr, + cmsys::auto_ptr<cmCompiledGeneratorExpression> condition, + bool inputIsContent) + : Input(input) + , OutputFileExpr(outputFileExpr) + , Condition(condition) + , InputIsContent(inputIsContent) { } -void cmGeneratorExpressionEvaluationFile::Generate(cmLocalGenerator* lg, - const std::string& config, - const std::string& lang, - cmCompiledGeneratorExpression* inputExpression, - std::map<std::string, std::string> &outputFiles, mode_t perm) +void cmGeneratorExpressionEvaluationFile::Generate( + cmLocalGenerator* lg, const std::string& config, const std::string& lang, + cmCompiledGeneratorExpression* inputExpression, + std::map<std::string, std::string>& outputFiles, mode_t perm) { std::string rawCondition = this->Condition->GetInput(); - if (!rawCondition.empty()) - { - std::string condResult = this->Condition->Evaluate(lg, - config, - false, 0, 0, 0, lang); - if (condResult == "0") - { + if (!rawCondition.empty()) { + std::string condResult = + this->Condition->Evaluate(lg, config, false, 0, 0, 0, lang); + if (condResult == "0") { return; - } - if (condResult != "1") - { + } + if (condResult != "1") { std::ostringstream e; - e << "Evaluation file condition \"" << rawCondition << "\" did " - "not evaluate to valid content. Got \"" << condResult << "\"."; + e << "Evaluation file condition \"" << rawCondition + << "\" did " + "not evaluate to valid content. Got \"" + << condResult << "\"."; lg->IssueMessage(cmake::FATAL_ERROR, e.str()); return; - } } + } + + const std::string outputFileName = + this->OutputFileExpr->Evaluate(lg, config, false, 0, 0, 0, lang); + const std::string outputContent = + inputExpression->Evaluate(lg, config, false, 0, 0, 0, lang); + + std::map<std::string, std::string>::iterator it = + outputFiles.find(outputFileName); - const std::string outputFileName - = this->OutputFileExpr->Evaluate(lg, config, - false, 0, 0, 0, lang); - const std::string outputContent - = inputExpression->Evaluate(lg, - config, - false, 0, 0, 0, lang); - - std::map<std::string, std::string>::iterator it - = outputFiles.find(outputFileName); - - if(it != outputFiles.end()) - { - if (it->second == outputContent) - { + if (it != outputFiles.end()) { + if (it->second == outputContent) { return; - } + } std::ostringstream e; e << "Evaluation file to be written multiple times for different " "configurations or languages with different content:\n " << outputFileName; lg->IssueMessage(cmake::FATAL_ERROR, e.str()); return; - } + } lg->GetMakefile()->AddCMakeOutputFile(outputFileName.c_str()); this->Files.push_back(outputFileName); @@ -91,94 +83,82 @@ void cmGeneratorExpressionEvaluationFile::Generate(cmLocalGenerator* lg, cmGeneratedFileStream fout(outputFileName.c_str()); fout.SetCopyIfDifferent(true); fout << outputContent; - if (fout.Close() && perm) - { + if (fout.Close() && perm) { cmSystemTools::SetPermissions(outputFileName.c_str(), perm); - } + } } void cmGeneratorExpressionEvaluationFile::CreateOutputFile( - cmLocalGenerator *lg, std::string const& config) + cmLocalGenerator* lg, std::string const& config) { std::vector<std::string> enabledLanguages; - cmGlobalGenerator *gg = lg->GetGlobalGenerator(); + cmGlobalGenerator* gg = lg->GetGlobalGenerator(); gg->GetEnabledLanguages(enabledLanguages); - for(std::vector<std::string>::const_iterator le = enabledLanguages.begin(); - le != enabledLanguages.end(); ++le) - { - std::string name = this->OutputFileExpr->Evaluate(lg, - config, - false, 0, 0, 0, *le); + for (std::vector<std::string>::const_iterator le = enabledLanguages.begin(); + le != enabledLanguages.end(); ++le) { + std::string name = + this->OutputFileExpr->Evaluate(lg, config, false, 0, 0, 0, *le); cmSourceFile* sf = lg->GetMakefile()->GetOrCreateSource(name); sf->SetProperty("GENERATED", "1"); - gg->SetFilenameTargetDepends(sf, - this->OutputFileExpr->GetSourceSensitiveTargets()); - } + gg->SetFilenameTargetDepends( + sf, this->OutputFileExpr->GetSourceSensitiveTargets()); + } } -void cmGeneratorExpressionEvaluationFile::Generate(cmLocalGenerator *lg) +void cmGeneratorExpressionEvaluationFile::Generate(cmLocalGenerator* lg) { mode_t perm = 0; std::string inputContent; - if (this->InputIsContent) - { + if (this->InputIsContent) { inputContent = this->Input; - } - else - { + } else { lg->GetMakefile()->AddCMakeDependFile(this->Input.c_str()); cmSystemTools::GetPermissions(this->Input.c_str(), perm); cmsys::ifstream fin(this->Input.c_str()); - if(!fin) - { + if (!fin) { std::ostringstream e; e << "Evaluation file \"" << this->Input << "\" cannot be read."; lg->IssueMessage(cmake::FATAL_ERROR, e.str()); return; - } + } std::string line; std::string sep; - while(cmSystemTools::GetLineFromStream(fin, line)) - { + while (cmSystemTools::GetLineFromStream(fin, line)) { inputContent += sep + line; sep = "\n"; - } - inputContent += sep; } + inputContent += sep; + } cmListFileBacktrace lfbt = this->OutputFileExpr->GetBacktrace(); cmGeneratorExpression contentGE(lfbt); - cmsys::auto_ptr<cmCompiledGeneratorExpression> inputExpression - = contentGE.Parse(inputContent); + cmsys::auto_ptr<cmCompiledGeneratorExpression> inputExpression = + contentGE.Parse(inputContent); std::map<std::string, std::string> outputFiles; std::vector<std::string> allConfigs; lg->GetMakefile()->GetConfigurations(allConfigs); - if (allConfigs.empty()) - { + if (allConfigs.empty()) { allConfigs.push_back(""); - } + } std::vector<std::string> enabledLanguages; - cmGlobalGenerator *gg = lg->GetGlobalGenerator(); + cmGlobalGenerator* gg = lg->GetGlobalGenerator(); gg->GetEnabledLanguages(enabledLanguages); - for(std::vector<std::string>::const_iterator le = enabledLanguages.begin(); - le != enabledLanguages.end(); ++le) - { - for(std::vector<std::string>::const_iterator li = allConfigs.begin(); - li != allConfigs.end(); ++li) - { + for (std::vector<std::string>::const_iterator le = enabledLanguages.begin(); + le != enabledLanguages.end(); ++le) { + for (std::vector<std::string>::const_iterator li = allConfigs.begin(); + li != allConfigs.end(); ++li) { this->Generate(lg, *li, *le, inputExpression.get(), outputFiles, perm); - if(cmSystemTools::GetFatalErrorOccured()) - { + if (cmSystemTools::GetFatalErrorOccured()) { return; - } } } + } } |