| 1 | //===--- reexport_overridden-d1.h - test input file for iwyu --------------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | // In order for a method to be overridden, its base class must already be |
| 11 | // included, which must in itself be self-sufficient. Thus, the function |
| 12 | // signature types should generally not trigger IWYU warnings here. |
| 13 | |
| 14 | #include "tests/cxx/reexport_overridden-i1.h" |
| 15 | |
| 16 | // IWYU should suggest to remove these fwd-decls: |
| 17 | class FwdAutoconvParam; |
| 18 | template <typename> |
| 19 | class IndirectTemplate; |
| 20 | |
| 21 | class Derived1 : public Base { |
| 22 | public: |
| 23 | // Return type fully defined in Base. |
| 24 | IndirectClass GetIndirect() override; |
| 25 | |
| 26 | // Return types forward-declared in Base. |
| 27 | FwdRetType ReturnType() override; |
| 28 | FwdRetType ReturnTypeUnusedInBody() override; |
| 29 | |
| 30 | // No need to forward-declare the return type even when it is aliased in Base. |
| 31 | IndirectClass ReturnAliasedInBase() override; |
| 32 | |
| 33 | IndirectTemplate<FwdRetType> ReturnTemplate() override; |
| 34 | |
| 35 | // The using-declaration should be reported but the forward-declaration |
| 36 | // should not. |
| 37 | // IWYU: ns::FwdRetType is...*reexport_overridden-i3.h...*for using decl |
| 38 | ns::FwdRetType ReturnPulledInOtherNSInDerived() override; |
| 39 | |
| 40 | // Unused argument available from Base. |
| 41 | void ArgumentUnused(const IndirectClass& x) override; |
| 42 | |
| 43 | // Unused argument available from Base, in inline method. |
| 44 | void ArgumentUnusedInline(const IndirectClass& x) override { |
| 45 | } |
| 46 | |
| 47 | // The types fully used by inline definitions should be reported. |
| 48 | // IWYU: Struct is...*reexport_overridden-i3.h |
| 49 | void ArgumentByValueInline(Struct) override { |
| 50 | } |
| 51 | |
| 52 | // Parameter with implicit conversion forward-declared in Base. |
| 53 | void TakeFwdAutoconvParam(FwdAutoconvParam) override; |
| 54 | |
| 55 | // Type alias declaration should be reported here (moreover, it is not used |
| 56 | // in the declaration from Base). |
| 57 | // IWYU: Alias is...*reexport_overridden-i3.h |
| 58 | void TakeNoConvParam(Alias) override; |
| 59 | |
| 60 | // Despite the declaration in Base doesn't mention IndirectClass explicitly, |
| 61 | // its (forward-)declaration should nevertheless be already accessible. |
| 62 | void TakeAliasedInBaseParam(IndirectClass) override; |
| 63 | |
| 64 | void TakeTemplate(IndirectTemplate<IndirectClass>) override; |
| 65 | void TakeSpecializedTemplate(IndirectTemplate<int>&) override; |
| 66 | |
| 67 | // IWYU: TemplatePtrAlias is...*reexport_overridden-i3.h |
| 68 | void TakeAliasedTemplatePtr(TemplatePtrAlias) override; |
| 69 | |
| 70 | // The using-declaration should be reported but the forward-declaration |
| 71 | // should not. |
| 72 | // IWYU: ns::IndirectClass is...*reexport_overridden-i3.h...*for using decl |
| 73 | void TakePulledInOtherNSInDerived(ns::IndirectClass) override; |
| 74 | |
| 75 | // IWYU should not suggest IndirectClass fwd-declaration here. |
| 76 | // TODO: OuterTpl is not needed as well. |
| 77 | // IWYU: OuterTpl is...*reexport_overridden-i3.h |
| 78 | OuterTpl<IndirectClass>::Inner GetNestedInTpl() override; |
| 79 | }; |
| 80 | |
| 81 | class Derived2 : public Derived1 { |
| 82 | public: |
| 83 | IndirectClass GetIndirect() override; |
| 84 | FwdRetType ReturnType() override; |
| 85 | // It's better to report Alias here so that it may be replaced |
| 86 | // by IndirectClass in Base without changing this file. |
| 87 | // IWYU: Alias is...*reexport_overridden-i3.h |
| 88 | Alias ReturnAliasedInBase() override; |
| 89 | void TakeFwdAutoconvParam(FwdAutoconvParam) override; |
| 90 | void TakeNoConvParam(IndirectClass) override; |
| 91 | }; |
| 92 | |
| 93 | /**** IWYU_SUMMARY |
| 94 | tests/cxx/reexport_overridden-d1.h should add these lines: |
| 95 | #include "tests/cxx/reexport_overridden-i3.h" |
| 96 | |
| 97 | tests/cxx/reexport_overridden-d1.h should remove these lines: |
| 98 | - class FwdAutoconvParam; // lines XX-XX |
| 99 | - template <typename> class IndirectTemplate; // lines XX-XX+1 |
| 100 | |
| 101 | The full include-list for tests/cxx/reexport_overridden-d1.h: |
| 102 | #include "tests/cxx/reexport_overridden-i1.h" // for Base |
| 103 | #include "tests/cxx/reexport_overridden-i3.h" // for Alias, FwdRetType, IndirectClass, OuterTpl, Struct, TemplatePtrAlias |
| 104 | ***** IWYU_SUMMARY */ |