[libc-commits] [PATCH] D114301: [libc] update tidy rules to fix variable formatting

Michael Jones via Phabricator via libc-commits libc-commits at lists.llvm.org
Wed Dec 1 16:02:55 PST 2021


michaelrj updated this revision to Diff 391157.
michaelrj added a comment.

add an exception for src/__support/CPP because it's supposed to match external code and thus might not match the internal format.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D114301/new/

https://reviews.llvm.org/D114301

Files:
  libc/CMakeLists.txt
  libc/cmake/modules/LLVMLibCObjectRules.cmake
  libc/src/.clang-tidy
  libc/src/__support/CPP/.clang-tidy


Index: libc/src/.clang-tidy
===================================================================
--- libc/src/.clang-tidy
+++ libc/src/.clang-tidy
@@ -1,6 +1,26 @@
-Checks: '-*,llvmlibc-*'
+Checks: '-*,llvmlibc-*,readability-identifier-naming'
 HeaderFilterRegex: '.*'
 WarningsAsErrors: 'llvmlibc-*'
 CheckOptions:
   - key:             llvmlibc-restrict-system-libc-headers.Includes
     value:           '-*, linux/*, asm/*.h, asm-generic/*.h'
+  - key:             readability-identifier-naming.ClassCase
+    value:           CamelCase
+  - key:             readability-identifier-naming.StructCase
+    value:           aNy_CasE
+  - key:             readability-identifier-naming.MemberCase
+    value:           aNy_CasE
+  - key:             readability-identifier-naming.VariableCase
+    value:           lower_case
+  - key:             readability-identifier-naming.FunctionCase
+    value:           lower_case
+  - key:             readability-identifier-naming.FunctionIgnoredRegexp
+    value:           "^_\\w+$"
+  - key:             readability-identifier-naming.GlobalFunctionCase
+    value:           aNy_CasE
+  - key:             readability-identifier-naming.GlobalFunctionIgnoredRegexp
+    value:           "^.+$"
+  - key:             readability-identifier-naming.ConstexprVariableCase
+    value:           UPPER_CASE
+  - key:             readability-identifier-naming.GetConfigPerFile
+    value:           true
Index: libc/cmake/modules/LLVMLibCObjectRules.cmake
===================================================================
--- libc/cmake/modules/LLVMLibCObjectRules.cmake
+++ libc/cmake/modules/LLVMLibCObjectRules.cmake
@@ -232,6 +232,7 @@
       # these.
       COMMAND $<TARGET_FILE:clang-tidy>
               "--extra-arg=-fno-caret-diagnostics" --quiet
+              "--export-fixes=${CMAKE_CURRENT_BINARY_DIR}/${target_name}.yaml"
               # Path to directory containing compile_commands.json
               -p ${PROJECT_BINARY_DIR}
               ${ADD_ENTRYPOINT_OBJ_SRCS}
Index: libc/CMakeLists.txt
===================================================================
--- libc/CMakeLists.txt
+++ libc/CMakeLists.txt
@@ -55,6 +55,12 @@
   if("clang-tools-extra" IN_LIST LLVM_ENABLE_PROJECTS
              AND "clang" IN_LIST LLVM_ENABLE_PROJECTS)
     add_custom_target(lint-libc)
+    if(NOT EXISTS "${LIBC_BUILD_DIR}/.clang-tidy")
+      # add a no-op clang tidy file for the build directory so that the tidy 
+      # rules don't attempt to format the generated code.
+      file(WRITE ${LIBC_BUILD_DIR}/.clang-tidy "#InheritParentConfig: false
+      Checks: cppcoreguidelines-avoid-goto")
+    endif()
   else()
     message(FATAL_ERROR "
       'clang' and 'clang-tools-extra' are required in LLVM_ENABLE_PROJECTS to


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D114301.391157.patch
Type: text/x-patch
Size: 2778 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20211202/37979a12/attachment.bin>


More information about the libc-commits mailing list