diff options
5 files changed, 25 insertions, 3 deletions
diff --git a/clang/lib/AST/DeclCXX.cpp b/clang/lib/AST/DeclCXX.cpp index b00b8a0ea9c..d905fcf13a4 100644 --- a/clang/lib/AST/DeclCXX.cpp +++ b/clang/lib/AST/DeclCXX.cpp @@ -1272,7 +1272,7 @@ const CXXRecordDecl *CXXRecordDecl::getTemplateInstantiationPattern() const { break; CTD = NewCTD; } - return CTD->getTemplatedDecl(); + return CTD->getTemplatedDecl()->getDefinition(); } if (auto *CTPSD = From.dyn_cast<ClassTemplatePartialSpecializationDecl *>()) { @@ -1281,7 +1281,7 @@ const CXXRecordDecl *CXXRecordDecl::getTemplateInstantiationPattern() const { break; CTPSD = NewCTPSD; } - return CTPSD; + return CTPSD->getDefinition(); } } @@ -1290,7 +1290,7 @@ const CXXRecordDecl *CXXRecordDecl::getTemplateInstantiationPattern() const { const CXXRecordDecl *RD = this; while (auto *NewRD = RD->getInstantiatedFromMemberClass()) RD = NewRD; - return RD; + return RD->getDefinition(); } } diff --git a/clang/test/Modules/Inputs/merge-template-pattern-visibility/a.h b/clang/test/Modules/Inputs/merge-template-pattern-visibility/a.h new file mode 100644 index 00000000000..7f9b6497e72 --- /dev/null +++ b/clang/test/Modules/Inputs/merge-template-pattern-visibility/a.h @@ -0,0 +1,5 @@ +template<typename, typename = int> struct A; +template<typename T> struct B; + +template<typename, typename> struct A {}; +template<typename T> struct B : A<T> {}; diff --git a/clang/test/Modules/Inputs/merge-template-pattern-visibility/b.h b/clang/test/Modules/Inputs/merge-template-pattern-visibility/b.h new file mode 100644 index 00000000000..5ed18e7e7c5 --- /dev/null +++ b/clang/test/Modules/Inputs/merge-template-pattern-visibility/b.h @@ -0,0 +1,9 @@ +template<typename, typename = int> struct A; +template<typename T> struct B; + +template<typename, typename> struct A {}; +template<typename T> struct B : A<T> {}; + +inline void f() { + B<int> bi; +} diff --git a/clang/test/Modules/Inputs/merge-template-pattern-visibility/module.modulemap b/clang/test/Modules/Inputs/merge-template-pattern-visibility/module.modulemap new file mode 100644 index 00000000000..ba97abbaa8e --- /dev/null +++ b/clang/test/Modules/Inputs/merge-template-pattern-visibility/module.modulemap @@ -0,0 +1,4 @@ +module X { + module A { header "a.h" } + module B { header "b.h" } +} diff --git a/clang/test/Modules/merge-template-pattern-visibility.cpp b/clang/test/Modules/merge-template-pattern-visibility.cpp new file mode 100644 index 00000000000..db759b5a46a --- /dev/null +++ b/clang/test/Modules/merge-template-pattern-visibility.cpp @@ -0,0 +1,4 @@ +// RUN: rm -rf %t +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fno-modules-error-recovery \ +// RUN: -fmodule-name=X -emit-module %S/Inputs/merge-template-pattern-visibility/module.modulemap -x c++ \ +// RUN: -fmodules-local-submodule-visibility |

