[clang] [llvm] Disentangle DISubprogram ODR type method uniquing from metadata uniquing (PR #217042)
Jeremy Morse via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 1 04:14:47 PDT 2026
================
@@ -1440,4 +1440,84 @@ TEST_F(CloneModule, GlobalWithBlockAddressesInitializer) {
ASSERT_NE(OriginalBa->getBasicBlock(), ClonedBa->getBasicBlock());
}
+TEST_F(CloneModule, ODRUniqueTypeMethodVerifier) {
+ // Test that the following IR, reduced from a self-host clang-22 compile,
+ // doesn't trip the verifier after cloning.
+ //
+ // The focus of the test is "operator!=" which is a DISubprogram that is:
+ // * a declaration (therefore not distinct),
+ // * has uniqued metadata fields used for ODR-type-method uniquing
+ // (linkage name, scope, template params),
+ // * and has other distinct metadata fields (type).
+ //
+ // The issue can be reproduced from C++ from this less-reduced C++:
+ // ```
+ // template <typename e> class BaseIt {
+ // public:
+ // [[gnu::nodebug]] BaseIt();
+ // bool operator!=(e);
+ // };
+ //
+ // template <typename TLambda> class It : public BaseIt<It<TLambda>> {
+ // public:
+ // It() {}
+ // [[gnu::nodebug]] It end();
+ // [[gnu::nodebug]] It begin();
+ // [[gnu::nodebug]] int *operator++();
+ // [[gnu::nodebug]] int operator*();
+ // };
+ //
+ // template <typename TLambda > [[gnu::nodebug]] It<TLambda> i(TLambda) {
+ // return {};
+ // }
+ //
+ // class ar {
+ // public:
+ // static auto lol() {
+ // return i([] {});
+ // }
+ // };
+ //
+ // [[gnu::nodebug]] ar au;
+ //
+ // bool func() {
+ // for ([[gnu::nodebug]] auto av : au.lol())
+ // ;
+ // }
+ // ```
+
+ StringRef IR = R"(
----------------
jmorse wrote:
SGTM, and thanks.
https://github.com/llvm/llvm-project/pull/217042
More information about the cfe-commits
mailing list