diff options
10 files changed, 79 insertions, 0 deletions
diff --git a/Utilities/ClangTidyModule/Tests/CMakeLists.txt b/Utilities/ClangTidyModule/Tests/CMakeLists.txt index 5bf0e89..b53d5d2 100644 --- a/Utilities/ClangTidyModule/Tests/CMakeLists.txt +++ b/Utilities/ClangTidyModule/Tests/CMakeLists.txt @@ -14,3 +14,4 @@ add_run_clang_tidy_test(cmake-use-cmstrlen) add_run_clang_tidy_test(cmake-use-cmsys-fstream) add_run_clang_tidy_test(cmake-use-bespoke-enum-class) add_run_clang_tidy_test(cmake-ostringstream-use-cmstrcat) +add_run_clang_tidy_test(cmake-use-pragma-once) diff --git a/Utilities/ClangTidyModule/Tests/cmake-use-pragma-once-stdout.txt b/Utilities/ClangTidyModule/Tests/cmake-use-pragma-once-stdout.txt new file mode 100644 index 0000000..e80e4a4 --- /dev/null +++ b/Utilities/ClangTidyModule/Tests/cmake-use-pragma-once-stdout.txt @@ -0,0 +1,25 @@ +cmake-use-pragma-once/cmake-use-pragma-once-both.h:1:1: warning: use #pragma once [cmake-use-pragma-once] +#ifndef BOTH_H +^~~~~~~~~~~~~~ +cmake-use-pragma-once/cmake-use-pragma-once-both.h:1:1: note: FIX-IT applied suggested code changes +cmake-use-pragma-once/cmake-use-pragma-once-both.h:2:1: note: FIX-IT applied suggested code changes +#define BOTH_H +^ +cmake-use-pragma-once/cmake-use-pragma-once-both.h:10:1: note: FIX-IT applied suggested code changes +#endif +^ +cmake-use-pragma-once/cmake-use-pragma-once-include-guards.h:1:1: warning: use #pragma once [cmake-use-pragma-once] +#ifndef INCLUDE_GUARDS_H +^~~~~~~~~~~~~~~~~~~~~~~~ +#pragma once +cmake-use-pragma-once/cmake-use-pragma-once-include-guards.h:1:1: note: FIX-IT applied suggested code changes +cmake-use-pragma-once/cmake-use-pragma-once-include-guards.h:2:1: note: FIX-IT applied suggested code changes +#define INCLUDE_GUARDS_H +^ +cmake-use-pragma-once/cmake-use-pragma-once-include-guards.h:9:1: note: FIX-IT applied suggested code changes +#endif +^ +cmake-use-pragma-once/cmake-use-pragma-once-neither.h:1:1: warning: use #pragma once [cmake-use-pragma-once] +int neither() +^ +cmake-use-pragma-once/cmake-use-pragma-once-neither.h:1:1: note: FIX-IT applied suggested code changes diff --git a/Utilities/ClangTidyModule/Tests/cmake-use-pragma-once.cxx b/Utilities/ClangTidyModule/Tests/cmake-use-pragma-once.cxx new file mode 100644 index 0000000..a571bc1 --- /dev/null +++ b/Utilities/ClangTidyModule/Tests/cmake-use-pragma-once.cxx @@ -0,0 +1,5 @@ +#include "cmake-use-pragma-once/cmake-use-pragma-once.h" + +#include "cmake-use-pragma-once/cmake-use-pragma-once-both.h" +#include "cmake-use-pragma-once/cmake-use-pragma-once-include-guards.h" +#include "cmake-use-pragma-once/cmake-use-pragma-once-neither.h" diff --git a/Utilities/ClangTidyModule/Tests/cmake-use-pragma-once/cmake-use-pragma-once-both-fixit.h b/Utilities/ClangTidyModule/Tests/cmake-use-pragma-once/cmake-use-pragma-once-both-fixit.h new file mode 100644 index 0000000..73c9720 --- /dev/null +++ b/Utilities/ClangTidyModule/Tests/cmake-use-pragma-once/cmake-use-pragma-once-both-fixit.h @@ -0,0 +1,8 @@ + + +#pragma once + +int both() +{ + return 0; +} diff --git a/Utilities/ClangTidyModule/Tests/cmake-use-pragma-once/cmake-use-pragma-once-both.h b/Utilities/ClangTidyModule/Tests/cmake-use-pragma-once/cmake-use-pragma-once-both.h new file mode 100644 index 0000000..fdf3cd3 --- /dev/null +++ b/Utilities/ClangTidyModule/Tests/cmake-use-pragma-once/cmake-use-pragma-once-both.h @@ -0,0 +1,10 @@ +#ifndef BOTH_H +#define BOTH_H +#pragma once + +int both() +{ + return 0; +} + +#endif diff --git a/Utilities/ClangTidyModule/Tests/cmake-use-pragma-once/cmake-use-pragma-once-include-guards-fixit.h b/Utilities/ClangTidyModule/Tests/cmake-use-pragma-once/cmake-use-pragma-once-include-guards-fixit.h new file mode 100644 index 0000000..36461c2 --- /dev/null +++ b/Utilities/ClangTidyModule/Tests/cmake-use-pragma-once/cmake-use-pragma-once-include-guards-fixit.h @@ -0,0 +1,6 @@ +#pragma once + +int includeGuards() +{ + return 0; +} diff --git a/Utilities/ClangTidyModule/Tests/cmake-use-pragma-once/cmake-use-pragma-once-include-guards.h b/Utilities/ClangTidyModule/Tests/cmake-use-pragma-once/cmake-use-pragma-once-include-guards.h new file mode 100644 index 0000000..687306d --- /dev/null +++ b/Utilities/ClangTidyModule/Tests/cmake-use-pragma-once/cmake-use-pragma-once-include-guards.h @@ -0,0 +1,9 @@ +#ifndef INCLUDE_GUARDS_H +#define INCLUDE_GUARDS_H + +int includeGuards() +{ + return 0; +} + +#endif diff --git a/Utilities/ClangTidyModule/Tests/cmake-use-pragma-once/cmake-use-pragma-once-neither-fixit.h b/Utilities/ClangTidyModule/Tests/cmake-use-pragma-once/cmake-use-pragma-once-neither-fixit.h new file mode 100644 index 0000000..eb5c6dd --- /dev/null +++ b/Utilities/ClangTidyModule/Tests/cmake-use-pragma-once/cmake-use-pragma-once-neither-fixit.h @@ -0,0 +1,5 @@ +#pragma once +int neither() +{ + return 0; +} diff --git a/Utilities/ClangTidyModule/Tests/cmake-use-pragma-once/cmake-use-pragma-once-neither.h b/Utilities/ClangTidyModule/Tests/cmake-use-pragma-once/cmake-use-pragma-once-neither.h new file mode 100644 index 0000000..c779ca0 --- /dev/null +++ b/Utilities/ClangTidyModule/Tests/cmake-use-pragma-once/cmake-use-pragma-once-neither.h @@ -0,0 +1,4 @@ +int neither() +{ + return 0; +} diff --git a/Utilities/ClangTidyModule/Tests/cmake-use-pragma-once/cmake-use-pragma-once.h b/Utilities/ClangTidyModule/Tests/cmake-use-pragma-once/cmake-use-pragma-once.h new file mode 100644 index 0000000..b0b2ea2 --- /dev/null +++ b/Utilities/ClangTidyModule/Tests/cmake-use-pragma-once/cmake-use-pragma-once.h @@ -0,0 +1,6 @@ +#pragma once + +int once() +{ + return 0; +} |