Revise C++ coding style using clang-format-18

Run the `clang-format.bash` script to update all our C and C++ code to a
new style defined by `.clang-format`.  Use `clang-format` version 18.

* 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.

Fixes: #26123
This commit is contained in:
Kitware Robot
2025-01-23 11:40:59 -05:00
committed by Brad King
parent c03bab9610
commit b2ba64add9
48 changed files with 78 additions and 67 deletions

View File

@@ -7,4 +7,4 @@ CMAKE-STDLIB-DETECT: libstdc++
#else
CMAKE-STDLIB-DETECT: UNKNOWN
#endif
// clang-format on
// clang-format on

View File

@@ -551,8 +551,7 @@ int cmCPackNSISGenerator::InitializeInternal()
}
} else {
cmCPackLogger(cmCPackLog::LOG_DEBUG,
"CPACK_CREATE_DESKTOP_LINKS: "
<< "not set" << std::endl);
"CPACK_CREATE_DESKTOP_LINKS: " << "not set" << std::endl);
}
std::ostringstream str;

View File

@@ -1733,9 +1733,7 @@ int cmCTestCoverageHandler::RunBullseyeCoverageBranch(
"run covbr: " << std::endl, this->Quiet);
if (!this->RunBullseyeCommand(cont, "covbr", nullptr, outputFile)) {
cmCTestLog(this->CTest, ERROR_MESSAGE,
"error running covbr for."
<< "\n");
cmCTestLog(this->CTest, ERROR_MESSAGE, "error running covbr for." << "\n");
return -1;
}
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,

View File

@@ -6,7 +6,7 @@
#include "cmCursesWidget.h"
#include "cmStateTypes.h"
#define ctrl(z) ((z)&037)
#define ctrl(z) ((z) & 037)
cmCursesOptionsWidget::cmCursesOptionsWidget(int width, int height, int left,
int top)

View File

@@ -31,7 +31,7 @@ public:
protected:
// Implement virtual methods from the superclass.
void ComplainAboutDuplicateTarget(
std::string const& /*targetName*/) const override{};
std::string const& /*targetName*/) const override {};
void ReportError(std::string const& errorMessage) const override;
bool GenerateMainFile(std::ostream& os) override;

View File

@@ -830,7 +830,7 @@ void cmGlobalGenerator::EnableLanguage(
// flag
needTestLanguage[lang] = true;
} // end if(!this->GetLanguageEnabled(lang) )
} // end loop over languages
} // end loop over languages
// **** Load the system specific information if not yet loaded
if (!mf->GetDefinition("CMAKE_SYSTEM_SPECIFIC_INFORMATION_LOADED")) {
@@ -939,7 +939,7 @@ void cmGlobalGenerator::EnableLanguage(
cmSystemTools::RemoveFile(compilerLangFile);
}
} // end if in try compile
} // end need test language
} // end need test language
// load linker configuration, if required
if (mf->GetDefinition(cmStrCat("CMAKE_", lang, "_USE_LINKER_INFORMATION"))

View File

@@ -42,10 +42,10 @@ public:
public:
Error(Location loc, std::string errMsg)
: location(loc)
, message(std::move(errMsg)){};
, message(std::move(errMsg)) {};
Error(std::string errMsg)
: location({ -1, -1 })
, message(std::move(errMsg)){};
, message(std::move(errMsg)) {};
std::string GetErrorMessage() const
{
std::string output = message;

View File

@@ -1503,7 +1503,7 @@ cmSystemTools::RenameResult cmSystemTools::RenameFile(
{
#ifdef _WIN32
# ifndef INVALID_FILE_ATTRIBUTES
# define INVALID_FILE_ATTRIBUTES ((DWORD)-1)
# define INVALID_FILE_ATTRIBUTES ((DWORD) - 1)
# endif
std::wstring const oldname_wstr =
SystemTools::ConvertToWindowsExtendedPath(oldname);

View File

@@ -26,6 +26,6 @@ public:
and to encode dates until the year 10000 in the patch level. */
#define CMake_VERSION_ENCODE_BASE KWIML_INT_UINT64_C(100000000)
#define CMake_VERSION_ENCODE(major, minor, patch) \
((((major)*1000u) * CMake_VERSION_ENCODE_BASE) + \
((((major) * 1000u) * CMake_VERSION_ENCODE_BASE) + \
(((minor) % 1000u) * CMake_VERSION_ENCODE_BASE) + \
(((patch) % CMake_VERSION_ENCODE_BASE)))

View File

@@ -3,7 +3,7 @@ struct
#ifdef _WIN32
__declspec(dllexport)
#endif
OnlyPlainLib1
OnlyPlainLib1
{
OnlyPlainLib1();

View File

@@ -4,4 +4,5 @@
#ifdef _WIN32
__declspec(dllexport)
#endif
OnlyPlainLib1 onlyPlainLib2();
OnlyPlainLib1
onlyPlainLib2();

View File

@@ -16,8 +16,7 @@ struct ExpectedPackResult
std::vector<cmCTestBinPackerAllocation> ExpectedBlockAllocations;
};
static const std::vector<ExpectedPackResult> expectedResults
{
static const std::vector<ExpectedPackResult> expectedResults{
/* clang-format off */
{
{ 2, 2, 2, 2 },

View File

@@ -7,14 +7,12 @@
#include "cmCTestResourceSpec.h"
#include "cmJSONState.h"
static const cmCTestResourceSpec spec{
{ {
/* clang-format off */
static const cmCTestResourceSpec spec{ { {
/* clang-format off */
{ "gpus", { { "0", 4 }, { "1", 8 }, { "2", 0 }, { "3", 8 } }, },
/* clang-format on */
} },
cmJSONState()
};
/* clang-format on */
} },
cmJSONState() };
static bool testInitializeFromResourceSpec()
{

View File

@@ -19,7 +19,7 @@ extern "C" {
#include <sys/stat.h>
#if !defined(S_ISDIR)
# define S_ISDIR(mode) ((mode)&_S_IFDIR)
# define S_ISDIR(mode) ((mode) & _S_IFDIR)
#endif
#ifdef COMPLEX_TEST_LINK_STATIC

View File

@@ -19,7 +19,7 @@ extern "C" {
#include <sys/stat.h>
#if !defined(S_ISDIR)
# define S_ISDIR(mode) ((mode)&_S_IFDIR)
# define S_ISDIR(mode) ((mode) & _S_IFDIR)
#endif
#ifdef COMPLEX_TEST_LINK_STATIC

View File

@@ -1,7 +1,8 @@
#ifdef _WIN32
__declspec(dllimport)
#endif
extern void dep1(void);
extern void
dep1(void);
#ifdef _WIN32
__declspec(dllexport)

View File

@@ -1,7 +1,8 @@
#ifdef _WIN32
__declspec(dllimport)
#endif
extern void dep8(void);
extern void
dep8(void);
#ifdef _WIN32
__declspec(dllexport)

View File

@@ -1,7 +1,8 @@
#ifdef _WIN32
__declspec(dllimport)
#endif
extern void dep9(void);
extern void
dep9(void);
#ifdef _WIN32
__declspec(dllexport)

View File

@@ -1,7 +1,8 @@
#ifdef _WIN32
__declspec(dllimport)
#endif
extern void dep6(void);
extern void
dep6(void);
#ifdef _WIN32
__declspec(dllexport)

View File

@@ -1,7 +1,8 @@
#ifdef _WIN32
__declspec(dllimport)
#endif
extern void dep7(void);
extern void
dep7(void);
#ifdef _WIN32
__declspec(dllexport)

View File

@@ -1,11 +1,13 @@
#ifdef _WIN32
__declspec(dllimport)
#endif
extern void dep3(void);
extern void
dep3(void);
#ifdef _WIN32
__declspec(dllimport)
#endif
extern void dep4(void);
extern void
dep4(void);
int main(void)
{

View File

@@ -26,7 +26,7 @@ int main(void)
b[i] = (float)(1000 * i);
}
/* compute on the GPU */
#pragma acc data copyin(a [0:n], b [0:n]) copyout(r [0:n])
#pragma acc data copyin(a[0 : n], b[0 : n]) copyout(r[0 : n])
{
vecaddgpu(r, a, b, n);
}

View File

@@ -25,7 +25,7 @@ int main(int, char*[])
auto a_ptr = a.data();
auto b_ptr = b.data();
auto r_ptr = r.data();
#pragma acc data copyin(a_ptr [0:n], b_ptr [0:n]) copyout(r_ptr [0:n])
#pragma acc data copyin(a_ptr[0 : n], b_ptr[0 : n]) copyout(r_ptr[0 : n])
{
vecaddgpu(r_ptr, a_ptr, b_ptr, n);
}

View File

@@ -2,6 +2,7 @@
__declspec(dllexport)
#endif
extern void foo(void)
extern void
foo(void)
{
}

View File

@@ -1,7 +1,8 @@
#ifdef _WIN32
__declspec(dllimport)
#endif
extern void foo(void);
extern void
foo(void);
#ifdef _WIN32
__declspec(dllexport)
#endif

View File

@@ -1,7 +1,8 @@
#ifdef _WIN32
__declspec(dllimport)
#endif
extern void bar();
extern void
bar();
int main(void)
{

View File

@@ -11,7 +11,7 @@ class LObject : public QObject
Q_OBJECT
public:
Q_SLOT
void aSlot(){};
void aSlot() {};
};
#endif

View File

@@ -8,7 +8,7 @@ class IncAPrivate : public QObject
{
Q_OBJECT
public:
IncAPrivate(){};
IncAPrivate() {};
};
IncA::IncA()

View File

@@ -6,7 +6,7 @@ class IncBPrivate : public QObject
{
Q_OBJECT
public:
IncBPrivate(){};
IncBPrivate() {};
};
IncB::IncB()

View File

@@ -4,8 +4,8 @@ class QItemC_Local : public QObject
{
Q_OBJECT
public:
QItemC_Local(){};
~QItemC_Local(){};
QItemC_Local() {};
~QItemC_Local() {};
};
void QItemC::go()

View File

@@ -4,8 +4,8 @@ class QItemD_Local : public QObject
{
Q_OBJECT
public:
QItemD_Local(){};
~QItemD_Local(){};
QItemD_Local() {};
~QItemD_Local() {};
};
void QItemD::go()

View File

@@ -7,7 +7,7 @@ class Object_h : public QObject
{
Q_OBJECT
Q_SLOT
void go(){};
void go() {};
};
#endif

View File

@@ -7,7 +7,7 @@ class Object_hh : public QObject
{
Q_OBJECT
Q_SLOT
void go(){};
void go() {};
};
#endif

View File

@@ -7,7 +7,7 @@ class Object_hpp : public QObject
{
Q_OBJECT
Q_SLOT
void go(){};
void go() {};
};
#endif

View File

@@ -7,7 +7,7 @@ class Object_hxx : public QObject
{
Q_OBJECT
Q_SLOT
void go(){};
void go() {};
};
#endif

View File

@@ -7,11 +7,13 @@
#ifdef _WIN32
__declspec(dllexport)
#endif
QString tr2xi18n(const char* text, const char* comment = 0);
QString
tr2xi18n(const char* text, const char* comment = 0);
#ifdef _WIN32
__declspec(dllexport)
#endif
QString tr2i18n(const char* text, const char* comment = 0);
QString
tr2i18n(const char* text, const char* comment = 0);
#endif

View File

@@ -4,7 +4,7 @@ class LocalObject : public QObject
{
Q_OBJECT
public:
LocalObject(){};
LocalObject() {};
};
void mocOnly()

View File

@@ -10,8 +10,8 @@ void hello()
{
printf("hello");
}
void Hello::operator delete[](void*){};
void Hello::operator delete(void*){};
void Hello::operator delete[](void*) {};
void Hello::operator delete(void*) {};
#ifdef HELLO_VFTABLE
HelloVFTable::HelloVFTable()

View File

@@ -1,7 +1,8 @@
#ifdef _WIN32
__declspec(dllimport)
#endif
extern void lib2(void);
extern void
lib2(void);
#ifdef _WIN32
__declspec(dllexport)

View File

@@ -1,4 +1,5 @@
#ifdef _WIN32
__declspec(dllimport)
#endif
extern void lib1(void);
extern void
lib1(void);

View File

@@ -1,4 +1,5 @@
#ifdef _WIN32
__declspec(dllimport)
#endif
extern void lib2(void);
extern void
lib2(void);

View File

@@ -3,7 +3,7 @@ class
#ifdef _WIN32
__declspec(dllexport)
#endif
Bar
Bar
{
public:
int bar();

View File

@@ -3,7 +3,7 @@ class
#ifdef _WIN32
__declspec(dllexport)
#endif
Foo
Foo
{
public:
int foo();

View File

@@ -19,7 +19,7 @@ private:
public:
Circle(double r)
: radius(r){};
: radius(r) {};
virtual double area(void);
virtual double perimeter(void);
};
@@ -31,7 +31,7 @@ private:
public:
Square(double w)
: width(w){};
: width(w) {};
virtual double area(void);
virtual double perimeter(void);
};

View File

@@ -1,7 +1,7 @@
#include <cstring>
template <size_t N>
constexpr size_t cmStrLen(const char (&/*str*/)[N])
constexpr size_t cmStrLen(const char (& /*str*/)[N])
{
return N - 1;
}

View File

@@ -1,7 +1,7 @@
#include <cstring>
template <size_t N>
constexpr size_t cmStrLen(const char (&/*str*/)[N])
constexpr size_t cmStrLen(const char (& /*str*/)[N])
{
return N - 1;
}

View File

@@ -221,7 +221,7 @@ inline auto data(C& c) -> decltype(c.data())
# else
inline constexpr auto data(C& c) noexcept(noexcept(c.data()))
# endif
-> decltype(c.data())
-> decltype(c.data())
{
return c.data();
}

View File

@@ -212,8 +212,9 @@ bool contains(Iterator first, Iterator last, Key const& key)
#if defined(__SUNPRO_CC)
template <typename Range, typename Key>
auto contains(Range const& range, Key const& key, detail::overload_selector<1>)
-> decltype(range.find(key) != range.end())
auto contains(Range const& range, Key const& key,
detail::overload_selector<1>) -> decltype(range.find(key) !=
range.end())
#else
template <
typename Range, typename Key,