Browse Source

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
Kitware Robot 8 months ago
parent
commit
b2ba64add9
48 changed files with 78 additions and 67 deletions
  1. 1 1
      Modules/CXX-DetectStdlib.h
  2. 1 2
      Source/CPack/cmCPackNSISGenerator.cxx
  3. 1 3
      Source/CTest/cmCTestCoverageHandler.cxx
  4. 1 1
      Source/CursesDialog/cmCursesOptionsWidget.cxx
  5. 1 1
      Source/cmExportTryCompileFileGenerator.h
  6. 2 2
      Source/cmGlobalGenerator.cxx
  7. 2 2
      Source/cmJSONState.h
  8. 1 1
      Source/cmSystemTools.cxx
  9. 1 1
      Source/cmVersion.h
  10. 1 1
      Tests/CMakeCommands/target_link_libraries/cmp0022/onlyplainlib1.h
  11. 2 1
      Tests/CMakeCommands/target_link_libraries/cmp0022/onlyplainlib2.h
  12. 1 2
      Tests/CMakeLib/testCTestBinPacker.cxx
  13. 5 7
      Tests/CMakeLib/testCTestResourceAllocator.cxx
  14. 1 1
      Tests/Complex/Executable/complex.cxx
  15. 1 1
      Tests/ComplexOneConfig/Executable/complex.cxx
  16. 2 1
      Tests/ExportImport/Export/install-RUNTIME_DEPENDENCY_SET/deplib.c
  17. 2 1
      Tests/ExportImport/Import/install-RUNTIME_DEPENDENCIES/lib.c
  18. 2 1
      Tests/ExportImport/Import/install-RUNTIME_DEPENDENCIES/mod.c
  19. 2 1
      Tests/ExportImport/Import/install-RUNTIME_DEPENDENCIES/sublib1.c
  20. 2 1
      Tests/ExportImport/Import/install-RUNTIME_DEPENDENCIES/sublib2.c
  21. 4 2
      Tests/ExportImport/Import/install-RUNTIME_DEPENDENCY_SET/main.c
  22. 1 1
      Tests/FindOpenACC/CTest/main.c
  23. 1 1
      Tests/FindOpenACC/CXXTest/main.cxx
  24. 2 1
      Tests/LibName/bar.c
  25. 2 1
      Tests/LibName/foo.c
  26. 2 1
      Tests/LibName/foobar.c
  27. 1 1
      Tests/QtAutogen/AutogenOriginDependsOn/testGenLib.hpp
  28. 1 1
      Tests/QtAutogen/MocOnly/IncA.cpp
  29. 1 1
      Tests/QtAutogen/MocOnly/IncB.cpp
  30. 2 2
      Tests/QtAutogen/MocSkipSource/qItemC.cpp
  31. 2 2
      Tests/QtAutogen/MocSkipSource/qItemD.cpp
  32. 1 1
      Tests/QtAutogen/SameName/object.h
  33. 1 1
      Tests/QtAutogen/SameName/object.hh
  34. 1 1
      Tests/QtAutogen/SameName/object.hpp
  35. 1 1
      Tests/QtAutogen/SameName/object.hxx
  36. 4 2
      Tests/QtAutogen/UicInterface/klocalizedstring.h
  37. 1 1
      Tests/QtAutogen/UicNoGui/MocOnly/main.cpp
  38. 2 2
      Tests/RunCMake/AutoExportDll/hello.cxx
  39. 2 1
      Tests/RunCMake/GenEx-TARGET_RUNTIME_DLLS/lib1.c
  40. 2 1
      Tests/RunCMake/VerifyHeaderSets/dir1/lib1.h
  41. 2 1
      Tests/RunCMake/VerifyHeaderSets/dir2/lib2.h
  42. 1 1
      Tests/StagingPrefix/Producer/bar.h
  43. 1 1
      Tests/StagingPrefix/Producer/foo.h
  44. 2 2
      Tests/UseSWIG/example.h
  45. 1 1
      Utilities/ClangTidyModule/Tests/cmake-use-cmstrlen-fixit.cxx
  46. 1 1
      Utilities/ClangTidyModule/Tests/cmake-use-cmstrlen.cxx
  47. 1 1
      Utilities/std/cm/bits/container_helpers.hxx
  48. 3 2
      Utilities/std/cmext/algorithm

+ 1 - 1
Modules/CXX-DetectStdlib.h

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

+ 1 - 2
Source/CPack/cmCPackNSISGenerator.cxx

@@ -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;

+ 1 - 3
Source/CTest/cmCTestCoverageHandler.cxx

@@ -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,

+ 1 - 1
Source/CursesDialog/cmCursesOptionsWidget.cxx

@@ -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)

+ 1 - 1
Source/cmExportTryCompileFileGenerator.h

@@ -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;

+ 2 - 2
Source/cmGlobalGenerator.cxx

@@ -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"))

+ 2 - 2
Source/cmJSONState.h

@@ -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;

+ 1 - 1
Source/cmSystemTools.cxx

@@ -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);

+ 1 - 1
Source/cmVersion.h

@@ -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)))

+ 1 - 1
Tests/CMakeCommands/target_link_libraries/cmp0022/onlyplainlib1.h

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

+ 2 - 1
Tests/CMakeCommands/target_link_libraries/cmp0022/onlyplainlib2.h

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

+ 1 - 2
Tests/CMakeLib/testCTestBinPacker.cxx

@@ -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 },

+ 5 - 7
Tests/CMakeLib/testCTestResourceAllocator.cxx

@@ -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()
 {

+ 1 - 1
Tests/Complex/Executable/complex.cxx

@@ -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

+ 1 - 1
Tests/ComplexOneConfig/Executable/complex.cxx

@@ -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

+ 2 - 1
Tests/ExportImport/Export/install-RUNTIME_DEPENDENCY_SET/deplib.c

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

+ 2 - 1
Tests/ExportImport/Import/install-RUNTIME_DEPENDENCIES/lib.c

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

+ 2 - 1
Tests/ExportImport/Import/install-RUNTIME_DEPENDENCIES/mod.c

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

+ 2 - 1
Tests/ExportImport/Import/install-RUNTIME_DEPENDENCIES/sublib1.c

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

+ 2 - 1
Tests/ExportImport/Import/install-RUNTIME_DEPENDENCIES/sublib2.c

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

+ 4 - 2
Tests/ExportImport/Import/install-RUNTIME_DEPENDENCY_SET/main.c

@@ -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)
 {

+ 1 - 1
Tests/FindOpenACC/CTest/main.c

@@ -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);
   }

+ 1 - 1
Tests/FindOpenACC/CXXTest/main.cxx

@@ -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);
   }

+ 2 - 1
Tests/LibName/bar.c

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

+ 2 - 1
Tests/LibName/foo.c

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

+ 2 - 1
Tests/LibName/foobar.c

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

+ 1 - 1
Tests/QtAutogen/AutogenOriginDependsOn/testGenLib.hpp

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

+ 1 - 1
Tests/QtAutogen/MocOnly/IncA.cpp

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

+ 1 - 1
Tests/QtAutogen/MocOnly/IncB.cpp

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

+ 2 - 2
Tests/QtAutogen/MocSkipSource/qItemC.cpp

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

+ 2 - 2
Tests/QtAutogen/MocSkipSource/qItemD.cpp

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

+ 1 - 1
Tests/QtAutogen/SameName/object.h

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

+ 1 - 1
Tests/QtAutogen/SameName/object.hh

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

+ 1 - 1
Tests/QtAutogen/SameName/object.hpp

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

+ 1 - 1
Tests/QtAutogen/SameName/object.hxx

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

+ 4 - 2
Tests/QtAutogen/UicInterface/klocalizedstring.h

@@ -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

+ 1 - 1
Tests/QtAutogen/UicNoGui/MocOnly/main.cpp

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

+ 2 - 2
Tests/RunCMake/AutoExportDll/hello.cxx

@@ -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()

+ 2 - 1
Tests/RunCMake/GenEx-TARGET_RUNTIME_DLLS/lib1.c

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

+ 2 - 1
Tests/RunCMake/VerifyHeaderSets/dir1/lib1.h

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

+ 2 - 1
Tests/RunCMake/VerifyHeaderSets/dir2/lib2.h

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

+ 1 - 1
Tests/StagingPrefix/Producer/bar.h

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

+ 1 - 1
Tests/StagingPrefix/Producer/foo.h

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

+ 2 - 2
Tests/UseSWIG/example.h

@@ -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);
 };

+ 1 - 1
Utilities/ClangTidyModule/Tests/cmake-use-cmstrlen-fixit.cxx

@@ -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;
 }

+ 1 - 1
Utilities/ClangTidyModule/Tests/cmake-use-cmstrlen.cxx

@@ -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;
 }

+ 1 - 1
Utilities/std/cm/bits/container_helpers.hxx

@@ -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();
 }

+ 3 - 2
Utilities/std/cmext/algorithm

@@ -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,