Skip to content

Conversation

@andykaylor
Copy link
Contributor

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.

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.
@llvmbot llvmbot added clang Clang issues not falling into any other category ClangIR Anything related to the ClangIR project labels Jan 30, 2025
@llvmbot
Copy link
Member

llvmbot commented Jan 30, 2025

@llvm/pr-subscribers-clangir

@llvm/pr-subscribers-clang

Author: Andy Kaylor (andykaylor)

Changes

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.


Full diff: https://github.com/llvm/llvm-project/pull/125128.diff

4 Files Affected:

  • (renamed) clang/include/clang/CIR/FrontendAction/.clang-tidy (+15)
  • (modified) clang/include/clang/CIR/LowerToLLVM.h (+2-1)
  • (added) clang/lib/CIR/FrontendAction/.clang-tidy (+16)
  • (modified) clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp (+6-6)
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

@lanza
Copy link
Member

lanza commented Jan 31, 2025

LGTM! Thanks!

Copy link
Collaborator

@AaronBallman AaronBallman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@andykaylor andykaylor merged commit fbf544c into llvm:main Jan 31, 2025
11 checks passed
@andykaylor andykaylor deleted the cir-tidy branch March 4, 2025 22:54
bcardosolopes pushed a commit to bcardosolopes/llvm-project that referenced this pull request Mar 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clang Clang issues not falling into any other category ClangIR Anything related to the ClangIR project

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants