diff options
Diffstat (limited to 'clang-tools-extra/test/clang-tidy')
13 files changed, 72 insertions, 0 deletions
diff --git a/clang-tools-extra/test/clang-tidy/Inputs/fuchsia-restrict-system-includes/a.h b/clang-tools-extra/test/clang-tidy/Inputs/fuchsia-restrict-system-includes/a.h new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/clang-tools-extra/test/clang-tidy/Inputs/fuchsia-restrict-system-includes/a.h diff --git a/clang-tools-extra/test/clang-tidy/Inputs/fuchsia-restrict-system-includes/system/cstdarg.h b/clang-tools-extra/test/clang-tidy/Inputs/fuchsia-restrict-system-includes/system/cstdarg.h new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/clang-tools-extra/test/clang-tidy/Inputs/fuchsia-restrict-system-includes/system/cstdarg.h diff --git a/clang-tools-extra/test/clang-tidy/Inputs/fuchsia-restrict-system-includes/system/cstdlib.h b/clang-tools-extra/test/clang-tidy/Inputs/fuchsia-restrict-system-includes/system/cstdlib.h new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/clang-tools-extra/test/clang-tidy/Inputs/fuchsia-restrict-system-includes/system/cstdlib.h diff --git a/clang-tools-extra/test/clang-tidy/Inputs/fuchsia-restrict-system-includes/system/j.h b/clang-tools-extra/test/clang-tidy/Inputs/fuchsia-restrict-system-includes/system/j.h new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/clang-tools-extra/test/clang-tidy/Inputs/fuchsia-restrict-system-includes/system/j.h diff --git a/clang-tools-extra/test/clang-tidy/Inputs/fuchsia-restrict-system-includes/system/r.h b/clang-tools-extra/test/clang-tidy/Inputs/fuchsia-restrict-system-includes/system/r.h new file mode 100644 index 00000000000..56757a701bf --- /dev/null +++ b/clang-tools-extra/test/clang-tidy/Inputs/fuchsia-restrict-system-includes/system/r.h @@ -0,0 +1 @@ +void f() {} diff --git a/clang-tools-extra/test/clang-tidy/Inputs/fuchsia-restrict-system-includes/system/s.h b/clang-tools-extra/test/clang-tidy/Inputs/fuchsia-restrict-system-includes/system/s.h new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/clang-tools-extra/test/clang-tidy/Inputs/fuchsia-restrict-system-includes/system/s.h diff --git a/clang-tools-extra/test/clang-tidy/Inputs/fuchsia-restrict-system-includes/system/t.h b/clang-tools-extra/test/clang-tidy/Inputs/fuchsia-restrict-system-includes/system/t.h new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/clang-tools-extra/test/clang-tidy/Inputs/fuchsia-restrict-system-includes/system/t.h diff --git a/clang-tools-extra/test/clang-tidy/Inputs/fuchsia-restrict-system-includes/system/transitive.h b/clang-tools-extra/test/clang-tidy/Inputs/fuchsia-restrict-system-includes/system/transitive.h new file mode 100644 index 00000000000..6dba769fb47 --- /dev/null +++ b/clang-tools-extra/test/clang-tidy/Inputs/fuchsia-restrict-system-includes/system/transitive.h @@ -0,0 +1,3 @@ +#include <r.h> +#include <t.h> +#include <s.h> diff --git a/clang-tools-extra/test/clang-tidy/Inputs/fuchsia-restrict-system-includes/transitive2.h b/clang-tools-extra/test/clang-tidy/Inputs/fuchsia-restrict-system-includes/transitive2.h new file mode 100644 index 00000000000..ea567885f34 --- /dev/null +++ b/clang-tools-extra/test/clang-tidy/Inputs/fuchsia-restrict-system-includes/transitive2.h @@ -0,0 +1,2 @@ +#include <s.h> +#include <t.h> diff --git a/clang-tools-extra/test/clang-tidy/fuchsia-restrict-system-includes-all.cpp b/clang-tools-extra/test/clang-tidy/fuchsia-restrict-system-includes-all.cpp new file mode 100644 index 00000000000..21f4b68b9c8 --- /dev/null +++ b/clang-tools-extra/test/clang-tidy/fuchsia-restrict-system-includes-all.cpp @@ -0,0 +1,10 @@ +// RUN: %check_clang_tidy %s fuchsia-restrict-system-includes %t \ +// RUN: -- -config="{CheckOptions: [{key: fuchsia-restrict-system-includes.Includes, value: ''}]}" \ +// RUN: -- -std=c++11 -I %S/Inputs/fuchsia-restrict-system-includes -isystem %S/Inputs/fuchsia-restrict-system-includes/system + +#include <cstdlib.h> +// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: system include cstdlib.h not allowed +#include <cstdarg.h> +// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: system include cstdarg.h not allowed +#include <t.h> +// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: system include t.h not allowed diff --git a/clang-tools-extra/test/clang-tidy/fuchsia-restrict-system-includes-glob.cpp b/clang-tools-extra/test/clang-tidy/fuchsia-restrict-system-includes-glob.cpp new file mode 100644 index 00000000000..334990dd84d --- /dev/null +++ b/clang-tools-extra/test/clang-tidy/fuchsia-restrict-system-includes-glob.cpp @@ -0,0 +1,9 @@ +// RUN: %check_clang_tidy %s fuchsia-restrict-system-includes %t \ +// RUN: -- -config="{CheckOptions: [{key: fuchsia-restrict-system-includes.Includes, value: 'cstd*'}]}" \ +// RUN: -- -std=c++11 -I %S/Inputs/fuchsia-restrict-system-includes -isystem %S/Inputs/fuchsia-restrict-system-includes/system + +#include <cstdlib.h> +#include <cstdarg.h> +#include <t.h> +// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: system include t.h not allowed +// CHECK-FIXES-NOT: #include <t.h> 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..a7cf1e6ecdc --- /dev/null +++ b/clang-tools-extra/test/clang-tidy/fuchsia-restrict-system-includes-headers.cpp @@ -0,0 +1,22 @@ +// RUN: mkdir %T/Inputs +// RUN: cp -r %S/Inputs/fuchsia-restrict-system-includes %T/Inputs/fuchsia-restrict-system-includes +// 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 +// RUN: rm -rf %T/Inputs + +// 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 +} 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 |

