Test reporting types hidden in tpl arguments
The full type use reporting in the three covered cases is ensured with excessive `CanIgnoreType` calls which check not only the type to be reported but also the type before dereferencing (which occurs to be in the resugaring map). This approach should be refactored in subsequent commits.
This commit is contained in:
parent
eb1697e002
commit
f9f4fd2eef
|
@ -120,6 +120,27 @@ void ViaMacro(const IndirectTemplate<IndirectClass>& ic) {
|
|||
IC_CALL_METHOD;
|
||||
}
|
||||
|
||||
// Test type use with member expression inside a template.
|
||||
|
||||
template <typename T>
|
||||
void MemberExprInside() {
|
||||
T* t = nullptr;
|
||||
(*t)->Method();
|
||||
}
|
||||
|
||||
class IndirectClass; // IndirectClassPtr doesn't provide IndirectClass.
|
||||
typedef IndirectClass* IndirectClassPtr;
|
||||
|
||||
namespace ns {
|
||||
using ::IndirectClassPtr;
|
||||
}
|
||||
|
||||
void Fn() {
|
||||
// IndirectClass is hidden by a pointer and (at least) two levels of sugar.
|
||||
// IWYU: IndirectClass is...*indirect.h
|
||||
MemberExprInside<ns::IndirectClassPtr>();
|
||||
}
|
||||
|
||||
/**** IWYU_SUMMARY
|
||||
|
||||
tests/cxx/member_expr.cc should add these lines:
|
||||
|
@ -127,6 +148,7 @@ tests/cxx/member_expr.cc should add these lines:
|
|||
|
||||
tests/cxx/member_expr.cc should remove these lines:
|
||||
- #include "tests/cxx/direct.h" // lines XX-XX
|
||||
- class IndirectClass; // lines XX-XX
|
||||
|
||||
The full include-list for tests/cxx/member_expr.cc:
|
||||
#include "tests/cxx/indirect.h" // for IndirectClass, IndirectTemplate
|
||||
|
|
|
@ -43,6 +43,12 @@ void ExpressionsBuiltinTypes() {
|
|||
}
|
||||
|
||||
// New- and delete-expressions with user-defined types.
|
||||
|
||||
template <typename T>
|
||||
void TplFnWithDelete(T p) {
|
||||
delete p;
|
||||
}
|
||||
|
||||
void ExpressionsUserTypes() {
|
||||
// IWYU: IndirectClass needs a declaration
|
||||
// IWYU: IndirectClass is...*indirect.h
|
||||
|
@ -55,6 +61,11 @@ void ExpressionsUserTypes() {
|
|||
IndirectClass* arr = new IndirectClass[4];
|
||||
// IWYU: IndirectClass is...*indirect.h
|
||||
delete[] arr;
|
||||
|
||||
// Hide the pointer type behind "decltype" sugar.
|
||||
decltype(elem) elem2 = nullptr;
|
||||
// IWYU: IndirectClass is...*indirect.h
|
||||
TplFnWithDelete(elem2);
|
||||
}
|
||||
|
||||
// Aligned allocation uses operator new(size_t, std::align_val_t) under the
|
||||
|
|
|
@ -103,6 +103,22 @@ SizeofTakingStructTplRef2<IndirectClass> sizeof_taking_struct5;
|
|||
// IWYU: IndirectClass needs a declaration
|
||||
SizeofTakingStructTplRef2<IndirectClass&> sizeof_taking_struct6;
|
||||
|
||||
// The same with some sugar.
|
||||
|
||||
// IWYU: IndirectClass is...*indirect.h
|
||||
SizeofTakingStruct<decltype(ref)> sizeof_taking_struct7;
|
||||
|
||||
// IWYU: IndirectClass is...*indirect.h
|
||||
SizeofTakingStructRef<decltype(dummy)> sizeof_taking_struct8;
|
||||
|
||||
SizeofTakingStructTpl<decltype(ref)> sizeof_taking_struct9;
|
||||
|
||||
SizeofTakingStructTplRef<decltype(dummy)> sizeof_taking_struct10;
|
||||
|
||||
// IWYU: IndirectClass is...*indirect.h
|
||||
SizeofTakingStructTplRef2<decltype(dummy)> sizeof_taking_struct11;
|
||||
|
||||
SizeofTakingStructTplRef2<decltype(ref)> sizeof_taking_struct12;
|
||||
|
||||
/**** IWYU_SUMMARY
|
||||
|
||||
|
|
Loading…
Reference in New Issue