Commit d9fd2f54 authored by Kitware Robot's avatar Kitware Robot Committed by Brad King

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.
parent 82df6dea

Too many changes to show.

To preserve performance only 229 of 229+ files are displayed.

#ifdef __cplusplus
# error "A C++ compiler has been selected for C."
#error "A C++ compiler has been selected for C."
#endif
#ifdef __CLASSIC_C__
# define const
#define const
#endif
#include "CMakeCompilerABI.h"
#ifdef __CLASSIC_C__
int main(argc, argv) int argc; char *argv[];
int main(argc, argv) int argc;
char* argv[];
#else
int main(int argc, char *argv[])
int main(int argc, char* argv[])
#endif
{
int require = 0;
......
#ifndef __cplusplus
# error "A C compiler has been selected for C++."
#error "A C compiler has been selected for C++."
#endif
#include "CMakeCompilerABI.h"
int main(int argc, char* argv[])
{
int require = 0;
......
/* Size of a pointer-to-data in bytes. */
#define SIZEOF_DPTR (sizeof(void*))
const char info_sizeof_dptr[] = {
'I', 'N', 'F', 'O', ':', 's', 'i', 'z', 'e', 'o', 'f', '_', 'd', 'p', 't', 'r', '[',
('0' + ((SIZEOF_DPTR / 10)%10)),
('0' + (SIZEOF_DPTR % 10)),
']','\0'
const char info_sizeof_dptr[] = {
'I', 'N', 'F', 'O', ':', 's', 'i', 'z', 'e', 'o', 'f', '_', 'd', 'p', 't',
'r', '[', ('0' + ((SIZEOF_DPTR / 10) % 10)), ('0' + (SIZEOF_DPTR % 10)), ']',
'\0'
/* clang-format needs this comment to break after the opening brace */
};
/* Application Binary Interface. */
#if defined(__sgi) && defined(_ABIO32)
# define ABI_ID "ELF O32"
#define ABI_ID "ELF O32"
#elif defined(__sgi) && defined(_ABIN32)
# define ABI_ID "ELF N32"
#define ABI_ID "ELF N32"
#elif defined(__sgi) && defined(_ABI64)
# define ABI_ID "ELF 64"
#define ABI_ID "ELF 64"
/* Check for (some) ARM ABIs.
* See e.g. http://wiki.debian.org/ArmEabiPort for some information on this. */
#elif defined(__GNU__) && defined(__ELF__) && defined(__ARM_EABI__)
# define ABI_ID "ELF ARMEABI"
#define ABI_ID "ELF ARMEABI"
#elif defined(__GNU__) && defined(__ELF__) && defined(__ARMEB__)
# define ABI_ID "ELF ARM"
#define ABI_ID "ELF ARM"
#elif defined(__GNU__) && defined(__ELF__) && defined(__ARMEL__)
# define ABI_ID "ELF ARM"
#define ABI_ID "ELF ARM"
#elif defined(__ELF__)
# define ABI_ID "ELF"
#define ABI_ID "ELF"
#endif
#if defined(ABI_ID)
......
......@@ -6,11 +6,13 @@ void* runner(void*);
int res = 0;
#ifdef __CLASSIC_C__
int main(){
int main()
{
int ac;
char*av[];
char* av[];
#else
int main(int ac, char*av[]){
int main(int ac, char* av[])
{
#endif
pthread_t tid[2];
pthread_create(&tid[0], 0, runner, (void*)1);
......@@ -22,17 +24,18 @@ int main(int ac, char*av[]){
pthread_join(tid[0], 0);
pthread_join(tid[1], 0);
if(ac > 1000){return *av[0];}
if (ac > 1000) {
return *av[0];
}
return res;
}
void* runner(void* args)
{
int cc;
for ( cc = 0; cc < 10; cc ++ )
{
for (cc = 0; cc < 10; cc++) {
printf("%p CC: %d\n", args, cc);
}
res ++;
}
res++;
return 0;
}
......@@ -3,24 +3,26 @@
#ifdef __cplusplus
extern "C"
#endif
char CHECK_FUNCTION_EXISTS();
char
CHECK_FUNCTION_EXISTS();
#ifdef __CLASSIC_C__
int main(){
int main()
{
int ac;
char*av[];
char* av[];
#else
int main(int ac, char*av[]){
int main(int ac, char* av[])
{
#endif
CHECK_FUNCTION_EXISTS();
if(ac > 1000)
{
if (ac > 1000) {
return *av[0];
}
}
return 0;
}
#else /* CHECK_FUNCTION_EXISTS */
#else /* CHECK_FUNCTION_EXISTS */
# error "CHECK_FUNCTION_EXISTS has to specify the function"
#error "CHECK_FUNCTION_EXISTS has to specify the function"
#endif /* CHECK_FUNCTION_EXISTS */
......@@ -3,18 +3,22 @@
extern int CHECK_VARIABLE_EXISTS;
#ifdef __CLASSIC_C__
int main(){
int main()
{
int ac;
char*av[];
char* av[];
#else
int main(int ac, char*av[]){
int main(int ac, char* av[])
{
#endif
if(ac > 1000){return *av[0];}
if (ac > 1000) {
return *av[0];
}
return CHECK_VARIABLE_EXISTS;
}
#else /* CHECK_VARIABLE_EXISTS */
#else /* CHECK_VARIABLE_EXISTS */
# error "CHECK_VARIABLE_EXISTS has to specify the variable"
#error "CHECK_VARIABLE_EXISTS has to specify the variable"
#endif /* CHECK_VARIABLE_EXISTS */
void my_module_(void) {}
void my_module_(void)
{
}
void mymodule_(void) {}
void mymodule_(void)
{
}
#include <iostream>
int main(int,char *[])
int main(int, char* [])
{
return 0;
}
int main(int, char*[])
int main(int, char* [])
{
int i;
for(int i=0; i < 1; ++i);
for (int i = 0; i < 1; ++i)
;
(void)i;
return 0;
}
#include <sstream>
int main(int, char*[])
int main(int, char* [])
{
std::ostringstream os;
os << "12345";
if(os.str().size() == 5)
{
if (os.str().size() == 5) {
return 0;
}
}
return -1;
}
#include <list>
int main(int, char*[])
int main(int, char* [])
{
std::list<int>();
return 0;
......
......@@ -39,22 +39,22 @@ cmCPackIFWGenerator::~cmCPackIFWGenerator()
{
}
bool cmCPackIFWGenerator::IsVersionLess(const char *version)
bool cmCPackIFWGenerator::IsVersionLess(const char* version)
{
return cmSystemTools::VersionCompare(cmSystemTools::OP_LESS,
FrameworkVersion.data(), version);
FrameworkVersion.data(), version);
}
bool cmCPackIFWGenerator::IsVersionGreater(const char *version)
bool cmCPackIFWGenerator::IsVersionGreater(const char* version)
{
return cmSystemTools::VersionCompare(cmSystemTools::OP_GREATER,
FrameworkVersion.data(), version);
FrameworkVersion.data(), version);
}
bool cmCPackIFWGenerator::IsVersionEqual(const char *version)
bool cmCPackIFWGenerator::IsVersionEqual(const char* version)
{
return cmSystemTools::VersionCompare(cmSystemTools::OP_EQUAL,
FrameworkVersion.data(), version);
FrameworkVersion.data(), version);
}
int cmCPackIFWGenerator::PackageFiles()
......@@ -72,168 +72,141 @@ int cmCPackIFWGenerator::PackageFiles()
ifwTmpFile += "/IFWOutput.log";
// Run repogen
if (!Installer.Repositories.empty())
{
if (!Installer.Repositories.empty()) {
std::string ifwCmd = RepoGen;
if(IsVersionLess("2.0.0"))
{
if (IsVersionLess("2.0.0")) {
ifwCmd += " -c " + this->toplevel + "/config/config.xml";
}
}
ifwCmd += " -p " + this->toplevel + "/packages";
if(!PkgsDirsVector.empty())
{
for(std::vector<std::string>::iterator it = PkgsDirsVector.begin();
it != PkgsDirsVector.end(); ++it)
{
if (!PkgsDirsVector.empty()) {
for (std::vector<std::string>::iterator it = PkgsDirsVector.begin();
it != PkgsDirsVector.end(); ++it) {
ifwCmd += " -p " + *it;
}
}
}
if (!OnlineOnly && !DownloadedPackages.empty())
{
if (!OnlineOnly && !DownloadedPackages.empty()) {
ifwCmd += " -i ";
std::set<cmCPackIFWPackage*>::iterator it
= DownloadedPackages.begin();
std::set<cmCPackIFWPackage*>::iterator it = DownloadedPackages.begin();
ifwCmd += (*it)->Name;
++it;
while(it != DownloadedPackages.end())
{
while (it != DownloadedPackages.end()) {
ifwCmd += "," + (*it)->Name;
++it;
}
}
}
ifwCmd += " " + this->toplevel + "/repository";
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Execute: " << ifwCmd
<< std::endl);
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Execute: " << ifwCmd << std::endl);
std::string output;
int retVal = 1;
cmCPackLogger(cmCPackLog::LOG_OUTPUT,
"- Generate repository" << std::endl);
cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- Generate repository"
<< std::endl);
bool res = cmSystemTools::RunSingleCommand(
ifwCmd.c_str(), &output, &output,
&retVal, 0, this->GeneratorVerbose, 0);
if ( !res || retVal )
{
ifwCmd.c_str(), &output, &output, &retVal, 0, this->GeneratorVerbose, 0);
if (!res || retVal) {
cmGeneratedFileStream ofs(ifwTmpFile.c_str());
ofs << "# Run command: " << ifwCmd << std::endl
<< "# Output:" << std::endl
<< output << std::endl;
cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem running IFW command: "
<< ifwCmd << std::endl
<< "Please check " << ifwTmpFile << " for errors"
<< std::endl);
<< ifwCmd << std::endl
<< "Please check " << ifwTmpFile << " for errors"
<< std::endl);
return 0;
}
cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- repository: " << this->toplevel
<< "/repository generated" << std::endl);
}
cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- repository: "
<< this->toplevel << "/repository generated" << std::endl);
}
// Run binary creator
{
std::string ifwCmd = BinCreator;
ifwCmd += " -c " + this->toplevel + "/config/config.xml";
ifwCmd += " -p " + this->toplevel + "/packages";
if(!PkgsDirsVector.empty())
{
for(std::vector<std::string>::iterator it = PkgsDirsVector.begin();
it != PkgsDirsVector.end(); ++it)
{
ifwCmd += " -p " + *it;
std::string ifwCmd = BinCreator;
ifwCmd += " -c " + this->toplevel + "/config/config.xml";
ifwCmd += " -p " + this->toplevel + "/packages";
if (!PkgsDirsVector.empty()) {
for (std::vector<std::string>::iterator it = PkgsDirsVector.begin();
it != PkgsDirsVector.end(); ++it) {
ifwCmd += " -p " + *it;
}
}
if (OnlineOnly)
{
ifwCmd += " --online-only";
}
else if (!DownloadedPackages.empty() && !Installer.Repositories.empty())
{
ifwCmd += " -e ";
std::set<cmCPackIFWPackage*>::iterator it
= DownloadedPackages.begin();
ifwCmd += (*it)->Name;
++it;
while(it != DownloadedPackages.end())
{
ifwCmd += "," + (*it)->Name;
if (OnlineOnly) {
ifwCmd += " --online-only";
} else if (!DownloadedPackages.empty() &&
!Installer.Repositories.empty()) {
ifwCmd += " -e ";
std::set<cmCPackIFWPackage*>::iterator it = DownloadedPackages.begin();
ifwCmd += (*it)->Name;
++it;
while (it != DownloadedPackages.end()) {
ifwCmd += "," + (*it)->Name;
++it;
}
}
else if (!DependentPackages.empty())
{
ifwCmd += " -i ";
// Binary
std::set<cmCPackIFWPackage*>::iterator bit = BinaryPackages.begin();
while(bit != BinaryPackages.end())
{
ifwCmd += (*bit)->Name + ",";
++bit;
} else if (!DependentPackages.empty()) {
ifwCmd += " -i ";
// Binary
std::set<cmCPackIFWPackage*>::iterator bit = BinaryPackages.begin();
while (bit != BinaryPackages.end()) {
ifwCmd += (*bit)->Name + ",";
++bit;
}
// Depend
DependenceMap::iterator it = DependentPackages.begin();
ifwCmd += it->second.Name;
++it;
while(it != DependentPackages.end())
{
ifwCmd += "," + it->second.Name;
// Depend
DependenceMap::iterator it = DependentPackages.begin();
ifwCmd += it->second.Name;
++it;
while (it != DependentPackages.end()) {
ifwCmd += "," + it->second.Name;
++it;
}
}
// TODO: set correct name for multipackages
if (!this->packageFileNames.empty())
{
ifwCmd += " " + packageFileNames[0];
}
else
{
ifwCmd += " installer";
// TODO: set correct name for multipackages
if (!this->packageFileNames.empty()) {
ifwCmd += " " + packageFileNames[0];
} else {
ifwCmd += " installer";
}
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Execute: " << ifwCmd
<< std::endl);
std::string output;
int retVal = 1;
cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- Generate package" << std::endl);
bool res = cmSystemTools::RunSingleCommand(
ifwCmd.c_str(), &output, &output,
&retVal, 0, this->GeneratorVerbose, 0);
if ( !res || retVal )
{
cmGeneratedFileStream ofs(ifwTmpFile.c_str());
ofs << "# Run command: " << ifwCmd << std::endl
<< "# Output:" << std::endl
<< output << std::endl;
cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem running IFW command: "
<< ifwCmd << std::endl
<< "Please check " << ifwTmpFile << " for errors"
<< std::endl);
return 0;
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Execute: " << ifwCmd << std::endl);
std::string output;
int retVal = 1;
cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- Generate package" << std::endl);
bool res = cmSystemTools::RunSingleCommand(
ifwCmd.c_str(), &output, &output, &retVal, 0, this->GeneratorVerbose, 0);
if (!res || retVal) {
cmGeneratedFileStream ofs(ifwTmpFile.c_str());
ofs << "# Run command: " << ifwCmd << std::endl
<< "# Output:" << std::endl
<< output << std::endl;
cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem running IFW command: "
<< ifwCmd << std::endl
<< "Please check " << ifwTmpFile << " for errors"
<< std::endl);
return 0;
}
}
return 1;
}
const char *cmCPackIFWGenerator::GetPackagingInstallPrefix()
const char* cmCPackIFWGenerator::GetPackagingInstallPrefix()
{
const char *defPrefix = cmCPackGenerator::GetPackagingInstallPrefix();
const char* defPrefix = cmCPackGenerator::GetPackagingInstallPrefix();
std::string tmpPref = defPrefix ? defPrefix : "";
if(this->Components.empty())
{
if (this->Components.empty()) {
tmpPref += "packages/" + GetRootPackageName() + "/data";
}
}
this->SetOption("CPACK_IFW_PACKAGING_INSTALL_PREFIX", tmpPref.c_str());
return this->GetOption("CPACK_IFW_PACKAGING_INSTALL_PREFIX");
}
const char *cmCPackIFWGenerator::GetOutputExtension()
const char* cmCPackIFWGenerator::GetOutputExtension()
{
return ExecutableSuffix.c_str();
}
......@@ -246,56 +219,43 @@ int cmCPackIFWGenerator::InitializeInternal()
const std::string RepoGenOpt = "CPACK_IFW_REPOGEN_EXECUTABLE";
const std::string FrameworkVersionOpt = "CPACK_IFW_FRAMEWORK_VERSION";
if(!this->IsSet(BinCreatorOpt) ||
!this->IsSet(RepoGenOpt) ||
!this->IsSet(FrameworkVersionOpt))
{
if (!this->IsSet(BinCreatorOpt) || !this->IsSet(RepoGenOpt) ||
!this->IsSet(FrameworkVersionOpt)) {
this->ReadListFile("CPackIFW.cmake");
}
}
// Look 'binarycreator' executable (needs)
const char *BinCreatorStr = this->GetOption(BinCreatorOpt);
if(!BinCreatorStr || cmSystemTools::IsNOTFOUND(BinCreatorStr))
{
const char* BinCreatorStr = this->GetOption(BinCreatorOpt);
if (!BinCreatorStr || cmSystemTools::IsNOTFOUND(BinCreatorStr)) {
BinCreator = "";
}
else
{
} else {
BinCreator = BinCreatorStr;
}
}
if (BinCreator.empty())
{
if (BinCreator.empty()) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
"Cannot find QtIFW compiler \"binarycreator\": "
"likely it is not installed, or not in your PATH"
<< std::endl);
<< std::endl);
return 0;
}
}
// Look 'repogen' executable (optional)
const char *RepoGenStr = this->GetOption(RepoGenOpt);
if(!RepoGenStr || cmSystemTools::IsNOTFOUND(RepoGenStr))
{
const char* RepoGenStr = this->GetOption(RepoGenOpt);
if (!RepoGenStr || cmSystemTools::IsNOTFOUND(RepoGenStr)) {
RepoGen = "";
}
else
{
} else {
RepoGen = RepoGenStr;
}
}
// Framework version
if(const char* FrameworkVersionSrt =
this->GetOption(FrameworkVersionOpt))
{
if (const char* FrameworkVersionSrt = this->GetOption(FrameworkVersionOpt)) {
FrameworkVersion = FrameworkVersionSrt;
}
else
{
} else {
FrameworkVersion = "1.9.9";
}
}
// Variables that Change Behavior
......@@ -304,158 +264,130 @@ int cmCPackIFWGenerator::InitializeInternal()
// Additional packages dirs
PkgsDirsVector.clear();
if(const char* dirs = this->GetOption("CPACK_IFW_PACKAGES_DIRECTORIES"))
{
cmSystemTools::ExpandListArgument(dirs,
PkgsDirsVector);
}
if (const char* dirs = this->GetOption("CPACK_IFW_PACKAGES_DIRECTORIES")) {
cmSystemTools::ExpandListArgument(dirs, PkgsDirsVector);
}
// Installer
Installer.Generator = this;
Installer.ConfigureFromOptions();
if (const char* ifwDownloadAll =
this->GetOption("CPACK_IFW_DOWNLOAD_ALL"))
{
if (const char* ifwDownloadAll = this->GetOption("CPACK_IFW_DOWNLOAD_ALL")) {
OnlineOnly = cmSystemTools::IsOn(ifwDownloadAll);
}