Skip to content

Commit f854d83

Browse files
authored
Update clang-format and clang-tidy dependancy (#1721)
**Context:** As part of updating dependancy versions for the ecosystem, we want to update formatting tools like `clang-tidy` and `clan-format`. **Description of the Change:** Bump `clang-tidy` and `clang-format` to v20. Note that I changed the Formatting CI job to install clang-format from the requirements this makes the job consistent with local development environment and allow us to use the latest version that are not yet available on the ubuntu repositories. **Benefits:** Using the latest formatting tools **Possible Drawbacks:** **Related GitHub Issues:** [sc-91016]
1 parent 1b5cdaa commit f854d83

File tree

11 files changed

+28
-29
lines changed

11 files changed

+28
-29
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Please complete the following checklist when submitting a PR:
55
- [ ] All new functions and code must be clearly commented and documented.
66

77
- [ ] Ensure that code is properly formatted by running `make format`.
8-
The latest version of black and `clang-format-14` are used in CI/CD to check formatting.
8+
The latest version of black and `clang-format-20` are used in CI/CD to check formatting.
99

1010
- [ ] All new features must include a unit test.
1111
Integration and frontend tests should be added to [`frontend/test`](../frontend/test/),

.github/workflows/check-formatting.yaml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,11 @@ jobs:
3434
runs-on: ubuntu-22.04
3535

3636
steps:
37-
- name: Install dependencies
38-
run: |
39-
sudo apt-get update
40-
sudo apt-get -y install clang-format-14
41-
4237
- name: Checkout code
4338
uses: actions/checkout@v4
4439

40+
- name: Install dependencies
41+
run: python3 -m pip install clang-format~=20.1
42+
4543
- name: Run clang-format
46-
run: python3 ./bin/format.py --check --verbose --cfversion 14 .
44+
run: python3 ./bin/format.py --check --verbose .

bin/format.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
IGNORE_PATTERNS = ["external", "build", "llvm-project", "mlir-hlo", "Enzyme"]
2727

28-
DEFAULT_CLANG_FORMAT_VERSION = 13
28+
DEFAULT_CLANG_FORMAT_VERSION = 20
2929

3030
CLANG_FMT_CNFG_PATH = "../.clang-format"
3131

doc/releases/changelog-dev.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@
9292
[(#1671)](https://github.com/PennyLaneAI/catalyst/pull/1671)
9393
[(#1681)](https://github.com/PennyLaneAI/catalyst/pull/1681)
9494

95+
* The clang-format and clang-tidy versions used by Catalyst have been updated to v20.
96+
[(#1721)](https://github.com/PennyLaneAI/catalyst/pull/1721)
97+
9598
* Support for Mac x86 has been removed. This includes Macs running on Intel processors.
9699
[(#1716)](https://github.com/PennyLaneAI/catalyst/pull/1716)
97100

mlir/include/Quantum/IR/QuantumOps.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,11 @@
3535
namespace mlir {
3636
namespace OpTrait {
3737

38-
template <typename ConcreteType> class UnitaryTrait : public TraitBase<ConcreteType, UnitaryTrait> {
39-
};
38+
template <typename ConcreteType>
39+
class UnitaryTrait : public TraitBase<ConcreteType, UnitaryTrait> {};
4040

4141
template <typename ConcreteType>
42-
class HermitianTrait : public TraitBase<ConcreteType, HermitianTrait> {
43-
};
42+
class HermitianTrait : public TraitBase<ConcreteType, HermitianTrait> {};
4443

4544
} // namespace OpTrait
4645
} // namespace mlir

mlir/lib/QEC/Transforms/CommuteCliffordPastPPM.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#include "mlir/Analysis/SliceAnalysis.h"
1818
#include "llvm/Support/Casting.h"
1919
#include "llvm/Support/Debug.h"
20-
//#include "mlir/Analysis/TopologicalSortUtils.h" // enable when updating llvm
20+
// #include "mlir/Analysis/TopologicalSortUtils.h" // enable when updating llvm
2121
#include "mlir/Transforms/TopologicalSortUtils.h"
2222

2323
#include "QEC/IR/QECDialect.h"

mlir/lib/QEC/Transforms/CommuteCliffordTPPR.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#define DEBUG_TYPE "commute_ppr"
1616

1717
#include "llvm/Support/Debug.h"
18-
//#include "mlir/Analysis/TopologicalSortUtils.h" // enable when updating llvm
18+
// #include "mlir/Analysis/TopologicalSortUtils.h" // enable when updating llvm
1919
#include "mlir/Transforms/TopologicalSortUtils.h"
2020

2121
#include "QEC/IR/QECDialect.h"

requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ PyYAML
1212

1313
# formatting/linting
1414
black
15-
clang-format==14.*
16-
clang-tidy~=16.0
15+
clang-format~=20.1
16+
clang-tidy~=20.1
1717
pylint
1818
isort
1919

runtime/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ check-tidy:
159159
-DCMAKE_BUILD_TYPE=$(BUILD_TYPE) \
160160
-DCMAKE_C_COMPILER=$(C_COMPILER) \
161161
-DCMAKE_CXX_COMPILER=$(CXX_COMPILER) \
162+
-DMLIR_INCLUDE_DIRS="$(abspath $(LLVM_DIR))/mlir/include" \
162163
-DRUNTIME_CLANG_TIDY=ON
163164

164165
cmake --build $(MK_DIR)/BuildTidy --target rt_capi -j$(NPROC)

runtime/include/QuantumDevice.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ struct QuantumDevice {
187187
*
188188
* @param gen Pointer to a Catalyst-managed Mersenne Twister instance.
189189
*/
190-
virtual void SetDevicePRNG(std::mt19937 *gen){};
190+
virtual void SetDevicePRNG(std::mt19937 *gen) {};
191191

192192
// ----------------------------------------
193193
// QUANTUM OPERATIONS

0 commit comments

Comments
 (0)