[clang] [Clang] Reapply CWG2369 "Ordering between constraints and substitution" (PR #122423)

Younan Zhang via cfe-commits cfe-commits at lists.llvm.org
Wed May 28 00:51:55 PDT 2025


================
@@ -522,6 +522,12 @@ enum class TemplateSubstitutionKind : char {
     llvm::PointerUnion<Decl *, DeclArgumentPack *> *
     findInstantiationOf(const Decl *D);
 
+    /// Similar to \p findInstantiationOf(), but it wouldn't assert if the
+    /// instantiation was not found within the current instantiation scope. This
+    /// is helpful for on-demand declaration instantiation.
+    llvm::PointerUnion<Decl *, DeclArgumentPack *> *
+    findInstantiationUnsafe(const Decl *D);
----------------
zyn0217 wrote:

I renamed it to `getInstantiationOfIfExists.`

> Finally, as interface, is there a reason these are returning a pointer to a pointer union?

It's pre-existing, we track the instantiated decls and packs together within a map.

Refactoring the interface (either the return type or the name) would bring a lot of churn, for which I think merits a separate PR.

https://github.com/llvm/llvm-project/pull/122423


More information about the cfe-commits mailing list