summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/test/clang-tidy/fuchsia-restrict-system-includes-headers.cpp
diff options
context:
space:
mode:
authorJulie Hockett <juliehockett@google.com>2018-05-11 19:23:15 +0000
committerJulie Hockett <juliehockett@google.com>2018-05-11 19:23:15 +0000
commit02aba94e768cbfb5e137d826e999527a5f4a96f4 (patch)
tree9f2cb629bf4a844ddeee3716eb5834cbdbcfad15 /clang-tools-extra/test/clang-tidy/fuchsia-restrict-system-includes-headers.cpp
parentc30365ce1da7e78962758a68dc5d7bf171102c53 (diff)
downloadbcm5719-llvm-02aba94e768cbfb5e137d826e999527a5f4a96f4.tar.gz
bcm5719-llvm-02aba94e768cbfb5e137d826e999527a5f4a96f4.zip
[clang-tidy] Adding RestrictSystemIncludes check to Fuchsia module
Adding a check to restrict system includes to a whitelist. Given a list of includes that are explicitly allowed, the check issues a fixit to remove any system include not on that list from the source file. Differential Revision: https://reviews.llvm.org/D43778 llvm-svn: 332125
Diffstat (limited to 'clang-tools-extra/test/clang-tidy/fuchsia-restrict-system-includes-headers.cpp')
-rw-r--r--clang-tools-extra/test/clang-tidy/fuchsia-restrict-system-includes-headers.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/clang-tools-extra/test/clang-tidy/fuchsia-restrict-system-includes-headers.cpp b/clang-tools-extra/test/clang-tidy/fuchsia-restrict-system-includes-headers.cpp
new file mode 100644
index 00000000000..109e1d5a459
--- /dev/null
+++ b/clang-tools-extra/test/clang-tidy/fuchsia-restrict-system-includes-headers.cpp
@@ -0,0 +1,20 @@
+// RUN: cp -r %S/Inputs/fuchsia-restrict-system-includes %T/Inputs
+// RUN: %check_clang_tidy %s fuchsia-restrict-system-includes %t \
+// RUN: -- -config="{CheckOptions: [{key: fuchsia-restrict-system-includes.Includes, value: 'transitive.h,s.h'}]}" \
+// RUN: -system-headers -header-filter=.* \
+// RUN: -- -std=c++11 -I %T/Inputs/fuchsia-restrict-system-includes -isystem %T/Inputs/fuchsia-restrict-system-includes/system
+// RUN: FileCheck -input-file=%T/Inputs/fuchsia-restrict-system-includes/transitive2.h %s -check-prefix=CHECK-FIXES
+
+// transitive.h includes <r.h> and <t.h>
+#include <transitive.h>
+// CHECK-MESSAGES: :1:1: warning: system include r.h not allowed, transitively included from {{(.*\/)*}}Inputs/fuchsia-restrict-system-includes/system/transitive.h
+// CHECK-MESSAGES: :2:1: warning: system include t.h not allowed, transitively included from {{(.*\/)*}}Inputs/fuchsia-restrict-system-includes/system/transitive.h
+
+// transitive.h includes <s.h> and <t.h>
+#include "transitive2.h"
+// CHECK-MESSAGES: :2:1: warning: system include t.h not allowed, transitively included from {{(.*\/)*}}Inputs/fuchsia-restrict-system-includes/transitive2.h
+// CHECK-FIXES-NOT: #include <t.h>
+
+int main() {
+ // f() is declared in r.h
+}
OpenPOWER on IntegriCloud