File tree 2 files changed +7
-2
lines changed 2 files changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -71,6 +71,8 @@ bool isIgnored(llvm::StringRef HeaderPath, HeaderFilter IgnoreHeaders) {
71
71
bool mayConsiderUnused (
72
72
const Inclusion &Inc, ParsedAST &AST,
73
73
const include_cleaner::PragmaIncludes *PI) {
74
+ if (PI && PI->shouldKeep (Inc.HashLine + 1 ))
75
+ return false ;
74
76
// FIXME(kirillbobyrev): We currently do not support the umbrella headers.
75
77
// System headers are likely to be standard library headers.
76
78
// Until we have good support for umbrella headers, don't warn about them.
@@ -82,8 +84,6 @@ bool mayConsiderUnused(
82
84
AST.getIncludeStructure ().getRealPath (HID));
83
85
assert (FE);
84
86
if (PI) {
85
- if (PI->shouldKeep (Inc.HashLine + 1 ))
86
- return false ;
87
87
// Check if main file is the public interface for a private header. If so we
88
88
// shouldn't diagnose it as unused.
89
89
if (auto PHeader = PI->getPublic (*FE); !PHeader.empty ()) {
Original file line number Diff line number Diff line change @@ -78,6 +78,8 @@ TEST(IncludeCleaner, StdlibUnused) {
78
78
auto TU = TestTU::withCode (R"cpp(
79
79
#include <list>
80
80
#include <queue>
81
+ #include <vector> // IWYU pragma: keep
82
+ #include <string> // IWYU pragma: export
81
83
std::list<int> x;
82
84
)cpp" );
83
85
// Layout of std library impl is not relevant.
@@ -86,10 +88,13 @@ TEST(IncludeCleaner, StdlibUnused) {
86
88
namespace std {
87
89
template <typename> class list {};
88
90
template <typename> class queue {};
91
+ template <typename> class vector {};
89
92
}
90
93
)cpp" ;
91
94
TU.AdditionalFiles [" list" ] = " #include <bits>" ;
92
95
TU.AdditionalFiles [" queue" ] = " #include <bits>" ;
96
+ TU.AdditionalFiles [" vector" ] = " #include <bits>" ;
97
+ TU.AdditionalFiles [" string" ] = " #include <bits>" ;
93
98
TU.ExtraArgs = {" -isystem" , testRoot ()};
94
99
auto AST = TU.build ();
95
100
IncludeCleanerFindings Findings = computeIncludeCleanerFindings (AST);
You can’t perform that action at this time.
0 commit comments