forked from include-what-you-use/include-what-you-use
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
I've decided to report only that overloaded function decls which are already directly `#include`d, as opposed to the suggestion in the removed TODO, so as to avoid lots of unwanted `#include`s in real-world STL cases (things like `std::begin` may be defined in many headers). When no overload is included directly but the name is qualified (i.e. can not be found via ADL), an arbitrary (the first one) overloaded declaration is suggested to keep the code compilable. Filtering of suitable overloads has not been done. This fixes include-what-you-use#636, include-what-you-use#823, include-what-you-use#1111, include-what-you-use#1293, and, partially, include-what-you-use#1250.
- Loading branch information
1 parent
5046c61
commit e98443e
Showing
10 changed files
with
192 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
//===--- overload_expr-d1.h - test input file for iwyu --------------------===// | ||
// | ||
// The LLVM Compiler Infrastructure | ||
// | ||
// This file is distributed under the University of Illinois Open Source | ||
// License. See LICENSE.TXT for details. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#include "tests/cxx/overload_expr-i1.h" | ||
#include "tests/cxx/using_overload-int.h" | ||
|
||
// 'using_overload-int.h' should be kept because it is directly included | ||
// (in contrast to '...-float.h'). | ||
|
||
template <typename T> | ||
T TplFn1() { | ||
return ns::add(T{}, T{}); | ||
} | ||
|
||
/**** IWYU_SUMMARY | ||
tests/cxx/overload_expr-d1.h should add these lines: | ||
tests/cxx/overload_expr-d1.h should remove these lines: | ||
- #include "tests/cxx/overload_expr-i1.h" // lines XX-XX | ||
The full include-list for tests/cxx/overload_expr-d1.h: | ||
#include "tests/cxx/using_overload-int.h" // for add | ||
***** IWYU_SUMMARY */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
//===--- overload_expr-d2.h - test input file for iwyu --------------------===// | ||
// | ||
// The LLVM Compiler Infrastructure | ||
// | ||
// This file is distributed under the University of Illinois Open Source | ||
// License. See LICENSE.TXT for details. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#include "tests/cxx/overload_expr-i1.h" | ||
|
||
// IWYU should report any of the files declaring 'ns::add' because it is | ||
// a qualified name. | ||
|
||
template <typename T> | ||
T TplFn2() { | ||
// IWYU: ns::add is...*using_overload-int.h | ||
return ns::add(T{}, T{}); | ||
} | ||
|
||
template <typename T> | ||
void TplFn3() { | ||
// It is allowed not to '#include' any definition of 'OverloadedFn' at this | ||
// point. | ||
return OverloadedFn(T{}); | ||
} | ||
|
||
/**** IWYU_SUMMARY | ||
tests/cxx/overload_expr-d2.h should add these lines: | ||
#include "tests/cxx/using_overload-int.h" | ||
tests/cxx/overload_expr-d2.h should remove these lines: | ||
- #include "tests/cxx/overload_expr-i1.h" // lines XX-XX | ||
The full include-list for tests/cxx/overload_expr-d2.h: | ||
#include "tests/cxx/using_overload-int.h" // for add | ||
***** IWYU_SUMMARY */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
//===--- overload_expr-i1.h - test input file for iwyu --------------------===// | ||
// | ||
// The LLVM Compiler Infrastructure | ||
// | ||
// This file is distributed under the University of Illinois Open Source | ||
// License. See LICENSE.TXT for details. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#include "tests/cxx/using_overload-int.h" | ||
#include "tests/cxx/using_overload-float.h" | ||
#include "tests/cxx/overload_expr-i2.h" | ||
#include "tests/cxx/overload_expr-i3.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
//===--- overload_expr-i2.h - test input file for iwyu --------------------===// | ||
// | ||
// The LLVM Compiler Infrastructure | ||
// | ||
// This file is distributed under the University of Illinois Open Source | ||
// License. See LICENSE.TXT for details. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
struct A; | ||
|
||
void OverloadedFn(A); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
//===--- overload_expr-i3.h - test input file for iwyu --------------------===// | ||
// | ||
// The LLVM Compiler Infrastructure | ||
// | ||
// This file is distributed under the University of Illinois Open Source | ||
// License. See LICENSE.TXT for details. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
void OverloadedFn(char); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
//===--- overload_expr.cc - test input file for iwyu ----------------------===// | ||
// | ||
// The LLVM Compiler Infrastructure | ||
// | ||
// This file is distributed under the University of Illinois Open Source | ||
// License. See LICENSE.TXT for details. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
// IWYU_ARGS: -Xiwyu --check_also="tests/cxx/overload_expr-d?.h" \ | ||
// -Xiwyu --mapping_file=tests/cxx/overload_expr.imp \ | ||
// -I . | ||
|
||
// Tests various cases of unresolved lookup expression handling. | ||
|
||
#include "tests/cxx/overload_expr-d1.h" | ||
#include "tests/cxx/overload_expr-d2.h" | ||
|
||
struct A {}; | ||
|
||
int main() { | ||
TplFn1<int>(); | ||
// IWYU: OverloadedFn is...*overload_expr-i2.h | ||
TplFn3<A>(); | ||
} | ||
|
||
/**** IWYU_SUMMARY | ||
tests/cxx/overload_expr.cc should add these lines: | ||
#include "tests/cxx/overload_expr-i2.h" | ||
tests/cxx/overload_expr.cc should remove these lines: | ||
The full include-list for tests/cxx/overload_expr.cc: | ||
#include "tests/cxx/overload_expr-d1.h" // for TplFn1 | ||
#include "tests/cxx/overload_expr-d2.h" // for TplFn3 | ||
#include "tests/cxx/overload_expr-i2.h" // for OverloadedFn | ||
***** IWYU_SUMMARY */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# The presence of the mapping file should not spoil IWYU analysis. | ||
[ | ||
{ "symbol": ["TplFn1", "private", "\"tests/cxx/overload_expr-d1.h\"", "public"] }, | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters