Author: Jonas Hahnfeld Date: 2023-08-02T08:16:46+02:00 New Revision: 99b54743106bae89217c3591ec7461266dbd00a4
URL: https://github.com/llvm/llvm-project/commit/99b54743106bae89217c3591ec7461266dbd00a4 DIFF: https://github.com/llvm/llvm-project/commit/99b54743106bae89217c3591ec7461266dbd00a4.diff LOG: [Modules] Add test for merging of template member parent This is a reduced test case originally meant to be addressed by https://reviews.llvm.org/D137787. It was recently fixed by commit 61c7a9140b ("Commit to a primary definition for a class when we load its first member."), noting the difficulty to come up with a reduced test case. This setup with four modules seems to fail consistently before the fix mentioned above with an assertion in CGExprCXX.cpp, CodeGenFunction::EmitCXXDestructorCall(): Assertion `ThisTy->getAsCXXRecordDecl() == DtorDecl->getParent() && "Pointer/Object mixup"' failed. Differential Revision: https://reviews.llvm.org/D156806 Added: clang/test/Modules/merge-template-members-parent.cpp Modified: Removed: ################################################################################ diff --git a/clang/test/Modules/merge-template-members-parent.cpp b/clang/test/Modules/merge-template-members-parent.cpp new file mode 100644 index 00000000000000..c51483b8428dd4 --- /dev/null +++ b/clang/test/Modules/merge-template-members-parent.cpp @@ -0,0 +1,64 @@ +// RUN: rm -rf %t +// RUN: mkdir %t +// RUN: split-file %s %t + +// RUN: %clang_cc1 -emit-obj -fmodules -fimplicit-module-maps -fmodules-cache-path=%t %t/merge.cpp -o %t/merge.o + +//--- V.h +#ifndef V_H +#define V_H +template <typename T> +struct V { + ~V() {} +}; +#endif + +//--- A.h +#include "V.h" + +void A(const V<unsigned long> &v); + +//--- B.h +#include "V.h" + +inline V<unsigned long> B() { + return {}; +} + +//--- C.h +#include "V.h" + +#include "A.h" + +class C { +public: + C(const V<unsigned long> &v) { + V<unsigned long> v2; + } +}; + +C GetC() { + return {{}}; +} + +// This include *MUST* come last. +#include "B.h" + +//--- module.modulemap +module "V" { header "V.h" export * } +module "A" { header "A.h" export * } +module "B" { header "B.h" export * } +module "C" { header "C.h" export * } + +//--- merge.cpp +#include "C.h" + +template <typename T> +C GetC_main() { + return {{}}; +} + +void f() { + GetC_main<float>(); + GetC(); +} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits