@@ -59,18 +59,20 @@ TEST(IncludeCleanerCheckTest, SuppressUnusedIncludes) {
59
59
#include "foo/qux.h"
60
60
#include "baz/qux/qux.h"
61
61
#include <vector>
62
+ #include <list>
62
63
)" ;
63
64
64
65
const char *PostCode = R"(
65
66
#include "bar.h"
66
67
#include "foo/qux.h"
67
68
#include <vector>
69
+ #include <list>
68
70
)" ;
69
71
70
72
std::vector<ClangTidyError> Errors;
71
73
ClangTidyOptions Opts;
72
74
Opts.CheckOptions [" IgnoreHeaders" ] = llvm::StringRef{llvm::formatv (
73
- " bar.h;{0};{1};vector" ,
75
+ " bar.h;{0};{1};vector;<list>; " ,
74
76
llvm::Regex::escape (appendPathFileSystemIndependent ({" foo" , " qux.h" })),
75
77
llvm::Regex::escape (appendPathFileSystemIndependent ({" baz" , " qux" })))};
76
78
EXPECT_EQ (
@@ -79,6 +81,7 @@ TEST(IncludeCleanerCheckTest, SuppressUnusedIncludes) {
79
81
PreCode, &Errors, " file.cpp" , std::nullopt, Opts,
80
82
{{" bar.h" , " #pragma once" },
81
83
{" vector" , " #pragma once" },
84
+ {" list" , " #pragma once" },
82
85
{appendPathFileSystemIndependent ({" foo" , " qux.h" }), " #pragma once" },
83
86
{appendPathFileSystemIndependent ({" baz" , " qux" , " qux.h" }),
84
87
" #pragma once" }}));
@@ -163,30 +166,37 @@ TEST(IncludeCleanerCheckTest, SuppressMissingIncludes) {
163
166
int BarResult = bar();
164
167
int BazResult = baz();
165
168
int QuxResult = qux();
169
+ int PrivResult = test();
170
+ std::vector x;
166
171
)" ;
167
172
168
173
ClangTidyOptions Opts;
169
174
Opts.CheckOptions [" IgnoreHeaders" ] = llvm::StringRef{
170
- " baz.h;" +
175
+ " public.h;<vector>; baz.h;" +
171
176
llvm::Regex::escape (appendPathFileSystemIndependent ({" foo" , " qux.h" }))};
172
177
std::vector<ClangTidyError> Errors;
173
178
EXPECT_EQ (PreCode, runCheckOnCode<IncludeCleanerCheck>(
174
179
PreCode, &Errors, " file.cpp" , std::nullopt, Opts,
175
180
{{" bar.h" , R"( #pragma once
176
181
#include "baz.h"
177
182
#include "foo/qux.h"
183
+ #include "private.h"
178
184
int bar();
185
+ namespace std { struct vector {}; }
179
186
)" },
180
187
{" baz.h" , R"( #pragma once
181
188
int baz();
182
189
)" },
190
+ {" private.h" , R"( #pragma once
191
+ // IWYU pragma: private, include "public.h"
192
+ int test();
193
+ )" },
183
194
{appendPathFileSystemIndependent ({" foo" , " qux.h" }),
184
195
R"( #pragma once
185
196
int qux();
186
197
)" }}));
187
198
}
188
199
189
-
190
200
TEST (IncludeCleanerCheckTest, MultipleTimeMissingInclude) {
191
201
const char *PreCode = R"(
192
202
#include "bar.h"
0 commit comments