[libc-commits] [libc] a5a79f6 - [libc] Add a .clang-tidy file for the toplevel libc directory.

Siva Chandra Reddy via libc-commits libc-commits at lists.llvm.org
Wed Dec 8 16:19:40 PST 2021


Author: Siva Chandra Reddy
Date: 2021-12-09T00:19:25Z
New Revision: a5a79f69d6262e46f38126198be7f58932e11080

URL: https://github.com/llvm/llvm-project/commit/a5a79f69d6262e46f38126198be7f58932e11080
DIFF: https://github.com/llvm/llvm-project/commit/a5a79f69d6262e46f38126198be7f58932e11080.diff

LOG: [libc] Add a .clang-tidy file for the toplevel libc directory.

Generation of the .yaml has been removed to prevent lint from
running with every ninja invocation. The new .clang-tidy file is copied
to the libc build directory so that generated files also get checked.

Reviewed By: michaelrj

Differential Revision: https://reviews.llvm.org/D115405

Added: 
    libc/.clang-tidy

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

Removed: 
    


################################################################################
diff  --git a/libc/.clang-tidy b/libc/.clang-tidy
new file mode 100644
index 0000000000000..a1dba68177bfe
--- /dev/null
+++ b/libc/.clang-tidy
@@ -0,0 +1,24 @@
+InheritParentConfig: false
+Checks: 'readability-identifier-naming'
+HeaderFilterRegex: '.*'
+CheckOptions:
+  - key:             readability-identifier-naming.ClassCase
+    value:           CamelCase
+  - key:             readability-identifier-naming.StructCase
+    value:           aNy_CasE
+  - key:             readability-identifier-naming.MemberCase
+    value:           lower_case
+  - key:             readability-identifier-naming.MemberIgnoredRegexp
+    value:           "^_[A-Za-z0-9_]+$"
+  - key:             readability-identifier-naming.VariableCase
+    value:           lower_case
+  - key:             readability-identifier-naming.VariableIgnoredRegexp
+    value:           "^_[A-Za-z0-9_]+$"
+  - key:             readability-identifier-naming.FunctionCase
+    value:           lower_case
+  - key:             readability-identifier-naming.FunctionIgnoredRegexp
+    value:           "^_[A-Za-z0-9_]+$"
+  - key:             readability-identifier-naming.ConstexprVariableCase
+    value:           UPPER_CASE
+  - key:             readability-identifier-naming.GetConfigPerFile
+    value:           true

diff  --git a/libc/CMakeLists.txt b/libc/CMakeLists.txt
index 7275ce42560ca..6e68246d6ceb4 100644
--- a/libc/CMakeLists.txt
+++ b/libc/CMakeLists.txt
@@ -55,12 +55,7 @@ if(LLVM_LIBC_ENABLE_LINTING)
   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()
+    file(COPY ${LIBC_SOURCE_DIR}/.clang-tidy DESTINATION ${LIBC_BUILD_DIR})
   else()
     message(FATAL_ERROR "
       'clang' and 'clang-tools-extra' are required in LLVM_ENABLE_PROJECTS to

diff  --git a/libc/cmake/modules/LLVMLibCObjectRules.cmake b/libc/cmake/modules/LLVMLibCObjectRules.cmake
index b1a22ba321ac0..69ec2160f1c0d 100644
--- a/libc/cmake/modules/LLVMLibCObjectRules.cmake
+++ b/libc/cmake/modules/LLVMLibCObjectRules.cmake
@@ -232,7 +232,6 @@ function(add_entrypoint_object target_name)
       # 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}
@@ -249,7 +248,6 @@ function(add_entrypoint_object target_name)
       COMMENT "Linting... ${target_name}"
       DEPENDS clang-tidy ${internal_target_name} ${ADD_ENTRYPOINT_OBJ_SRCS}
       WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
-      BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/${target_name}.yaml
     )
 
     add_custom_target(${fq_target_name}.__lint__

diff  --git a/libc/src/.clang-tidy b/libc/src/.clang-tidy
index 606e69632d7d0..b21d4c3928c8f 100644
--- a/libc/src/.clang-tidy
+++ b/libc/src/.clang-tidy
@@ -1,24 +1,7 @@
+InheritParentConfig: true
 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:           lower_case
-  - key:             readability-identifier-naming.VariableCase
-    value:           lower_case
-  - key:             readability-identifier-naming.VariableIgnoredRegexp
-    value:           "^_[A-Za-z0-9_]+$"
-  - key:             readability-identifier-naming.FunctionCase
-    value:           lower_case
-  - key:             readability-identifier-naming.FunctionIgnoredRegexp
-    value:           "^_[A-Za-z0-9_]+$"
-  - key:             readability-identifier-naming.ConstexprVariableCase
-    value:           UPPER_CASE
-  - key:             readability-identifier-naming.GetConfigPerFile
-    value:           true

diff  --git a/libc/src/__support/CPP/.clang-tidy b/libc/src/__support/CPP/.clang-tidy
index 29f78fdfbcbae..08b50cc0719b7 100644
--- a/libc/src/__support/CPP/.clang-tidy
+++ b/libc/src/__support/CPP/.clang-tidy
@@ -1,3 +1,4 @@
+InheritParentConfig: false
 Checks: '-*,llvmlibc-*'
 HeaderFilterRegex: '.*'
 WarningsAsErrors: 'llvmlibc-*'


        


More information about the libc-commits mailing list