diff options
author | Julie Hockett <juliehockett@google.com> | 2018-05-11 19:23:15 +0000 |
---|---|---|
committer | Julie Hockett <juliehockett@google.com> | 2018-05-11 19:23:15 +0000 |
commit | 02aba94e768cbfb5e137d826e999527a5f4a96f4 (patch) | |
tree | 9f2cb629bf4a844ddeee3716eb5834cbdbcfad15 /clang-tools-extra/test/clang-tidy/fuchsia-restrict-system-includes.cpp | |
parent | c30365ce1da7e78962758a68dc5d7bf171102c53 (diff) | |
download | bcm5719-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.cpp')
-rw-r--r-- | clang-tools-extra/test/clang-tidy/fuchsia-restrict-system-includes.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/clang-tools-extra/test/clang-tidy/fuchsia-restrict-system-includes.cpp b/clang-tools-extra/test/clang-tidy/fuchsia-restrict-system-includes.cpp new file mode 100644 index 00000000000..e2ba71060c3 --- /dev/null +++ b/clang-tools-extra/test/clang-tidy/fuchsia-restrict-system-includes.cpp @@ -0,0 +1,25 @@ +// RUN: %check_clang_tidy %s fuchsia-restrict-system-includes %t \ +// RUN: -- -config="{CheckOptions: [{key: fuchsia-restrict-system-includes.Includes, value: 's.h'}]}" \ +// RUN: -- -std=c++11 -I %S/Inputs/fuchsia-restrict-system-includes -isystem %S/Inputs/fuchsia-restrict-system-includes/system + +#include "a.h" + +#include <s.h> +#include <t.h> +// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: system include t.h not allowed +// CHECK-FIXES-NOT: #include <t.h> + +#include "s.h" +#include "t.h" +// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: system include t.h not allowed +// CHECK-FIXES-NOT: #include "t.h" + +#define foo <j.h> + +#include foo +// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: system include j.h not allowed +// CHECK-FIXES-NOT: #include foo + +#/* comment */ include /* comment */ foo +// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: system include j.h not allowed +// CHECK-FIXES-NOT: # /* comment */ include /* comment */ foo |