[clang] [llvm] Disentangle DISubprogram ODR type method uniquing from metadata uniquing (PR #217042)
Orlando Cazalet-Hyams via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 1 03:56:23 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"(
----------------
OCHyams wrote:
I have added a detailed comment - I've gone into quite a lot of detail so please do let me know if you think it needs to be pared back at all, or if it's not explaining what's going on clearly enough
https://github.com/llvm/llvm-project/pull/217042
More information about the cfe-commits
mailing list