[clang] [CIR] Fix some clang-tidy problems in CIR (PR #125128)

Andy Kaylor via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 30 14:50:04 PST 2025


https://github.com/andykaylor created https://github.com/llvm/llvm-project/pull/125128

This adds a .clang-tidy file to the clang/lib/CIR/FrontendAction directory, moves and updates the incorrectly located include/clang/CIR/FrontendAction .clang-tidy file, and updates two files from a recent commit to bring them into conformance with previously agreed upon rules for where to use LLVM naming conventions and where to use MLIR naming conventions.

>From c106bfb4b03ba0b30e91a6e1dbabd3c37dec722b Mon Sep 17 00:00:00 2001
From: Andy Kaylor <akaylor at nvidia.com>
Date: Thu, 30 Jan 2025 14:42:32 -0800
Subject: [PATCH] [CIR] Fix some clang-tidy problems in CIR

This adds a .clang-tidy file to the clang/lib/CIR/FrontendAction directory,
moves and updates the incorrectly located include/clang/CIR/FrontendAction
.clang-tidy file, and updates two files from a recent commit to bring them
into conformance with previously agreed upon rules for where to use LLVM
naming conventions and where to use MLIR naming conventions.
---
 .../FrontendAction}/.clang-tidy                  | 15 +++++++++++++++
 clang/include/clang/CIR/LowerToLLVM.h            |  3 ++-
 clang/lib/CIR/FrontendAction/.clang-tidy         | 16 ++++++++++++++++
 .../CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp    | 12 ++++++------
 4 files changed, 39 insertions(+), 7 deletions(-)
 rename clang/include/clang/{CIRFrontendAction => CIR/FrontendAction}/.clang-tidy (75%)
 create mode 100644 clang/lib/CIR/FrontendAction/.clang-tidy

diff --git a/clang/include/clang/CIRFrontendAction/.clang-tidy b/clang/include/clang/CIR/FrontendAction/.clang-tidy
similarity index 75%
rename from clang/include/clang/CIRFrontendAction/.clang-tidy
rename to clang/include/clang/CIR/FrontendAction/.clang-tidy
index ef88dbcec488c8..1a5dfe14180630 100644
--- a/clang/include/clang/CIRFrontendAction/.clang-tidy
+++ b/clang/include/clang/CIR/FrontendAction/.clang-tidy
@@ -51,3 +51,18 @@ Checks: >
         readability-simplify-boolean-expr,
         readability-simplify-subscript-expr,
         readability-use-anyofallof
+CheckOptions:
+  - key:             readability-identifier-naming.ClassCase
+    value:           CamelCase
+  - key:             readability-identifier-naming.EnumCase
+    value:           CamelCase
+  - key:             readability-identifier-naming.FunctionCase
+    value:           camelBack
+  - key:             readability-identifier-naming.MemberCase
+    value:           CamelCase
+  - key:             readability-identifier-naming.ParameterCase
+    value:           CamelCase
+  - key:             readability-identifier-naming.UnionCase
+    value:           CamelCase
+  - key:             readability-identifier-naming.VariableCase
+    value:           CamelCase
diff --git a/clang/include/clang/CIR/LowerToLLVM.h b/clang/include/clang/CIR/LowerToLLVM.h
index 9fd0706a91a5a0..afa1c1923ed516 100644
--- a/clang/include/clang/CIR/LowerToLLVM.h
+++ b/clang/include/clang/CIR/LowerToLLVM.h
@@ -29,7 +29,8 @@ namespace cir {
 
 namespace direct {
 std::unique_ptr<llvm::Module>
-lowerDirectlyFromCIRToLLVMIR(mlir::ModuleOp M, llvm::LLVMContext &Ctx);
+lowerDirectlyFromCIRToLLVMIR(mlir::ModuleOp mlirModule,
+                             llvm::LLVMContext &llvmCtx);
 } // namespace direct
 } // namespace cir
 
diff --git a/clang/lib/CIR/FrontendAction/.clang-tidy b/clang/lib/CIR/FrontendAction/.clang-tidy
new file mode 100644
index 00000000000000..cfb5bdb4bd1fe1
--- /dev/null
+++ b/clang/lib/CIR/FrontendAction/.clang-tidy
@@ -0,0 +1,16 @@
+InheritParentConfig: true
+CheckOptions:
+  - key:             readability-identifier-naming.ClassCase
+    value:           CamelCase
+  - key:             readability-identifier-naming.EnumCase
+    value:           CamelCase
+  - key:             readability-identifier-naming.FunctionCase
+    value:           camelBack
+  - key:             readability-identifier-naming.MemberCase
+    value:           CamelCase
+  - key:             readability-identifier-naming.ParameterCase
+    value:           CamelCase
+  - key:             readability-identifier-naming.UnionCase
+    value:           CamelCase
+  - key:             readability-identifier-naming.VariableCase
+    value:           CamelCase
diff --git a/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp b/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp
index 3687e482fa9bbc..63d2b51b428357 100644
--- a/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp
+++ b/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp
@@ -23,17 +23,17 @@ namespace cir {
 namespace direct {
 
 std::unique_ptr<llvm::Module>
-lowerDirectlyFromCIRToLLVMIR(mlir::ModuleOp MOp, LLVMContext &LLVMCtx) {
+lowerDirectlyFromCIRToLLVMIR(mlir::ModuleOp mlirModule, LLVMContext &llvmCtx) {
   llvm::TimeTraceScope scope("lower from CIR to LLVM directly");
 
-  std::optional<StringRef> ModuleName = MOp.getName();
-  auto M = std::make_unique<llvm::Module>(
-      ModuleName ? *ModuleName : "CIRToLLVMModule", LLVMCtx);
+  std::optional<StringRef> moduleName = mlirModule.getName();
+  auto llvmModule = std::make_unique<llvm::Module>(
+      moduleName ? *moduleName : "CIRToLLVMModule", llvmCtx);
 
-  if (!M)
+  if (!llvmModule)
     report_fatal_error("Lowering from LLVMIR dialect to llvm IR failed!");
 
-  return M;
+  return llvmModule;
 }
 } // namespace direct
 } // namespace cir



More information about the cfe-commits mailing list