[libc] Enable llvmlibc clang-tidy checks
authorPaula Toth <paulatoth@google.com>
Tue, 24 Mar 2020 03:33:56 +0000 (20:33 -0700)
committerPaula Toth <paulatoth@google.com>
Tue, 24 Mar 2020 03:34:39 +0000 (20:34 -0700)
Summary:
Add  clang-tidy for llvm-libc source directory.

Example of check in action:
```
/workspace/llvm-project/libc/src/string/strcpy.cpp:10:1: error: system include stdio.h not allowed [llvmlibc-restrict-system-libc-headers,-warnings-as-errors]
#include <stdio.h>
^~~~~~~~~~~~~~~~~~
```

Reviewers: sivachandra, abrachet

Reviewed By: sivachandra, abrachet

Subscribers: aheejin, MaskRay, tschuett, libc-commits

Tags: #libc-project

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

libc/src/.clang-tidy [new file with mode: 0644]
libc/src/math/round_redirector.cpp

diff --git a/libc/src/.clang-tidy b/libc/src/.clang-tidy
new file mode 100644 (file)
index 0000000..6d6043a
--- /dev/null
@@ -0,0 +1,6 @@
+Checks: '-*,llvmlibc-*'
+HeaderFilterRegex: '.*'
+WarningsAsErrors: 'llvmlibc-*'
+CheckOptions:
+  - key:             llvmlibc-restrict-system-libc-headers.Includes
+    value:           '-*, linux/*, asm/unistd.h'
index 6ee0744..c2847c8 100644 (file)
@@ -6,6 +6,8 @@
 //
 //===----------------------------------------------------------------------===//
 
+// Include okay for this redirector.
+// NOLINTNEXTLINE(llvmlibc-restrict-system-libc-headers)
 #include <math.h>
 
 namespace __llvm_libc {