[clang] [Clang] Guard against null in template instantiation process (PR #97913)

Younan Zhang via cfe-commits cfe-commits at lists.llvm.org
Sat Jul 6 18:40:09 PDT 2024


================
@@ -636,6 +636,9 @@ bool Sema::SetupConstraintScope(
             ? FD->getInstantiatedFromMemberFunction()
             : FD->getInstantiatedFromDecl();
 
+    if (!InstantiatedFrom)
+      return true;
+
----------------
zyn0217 wrote:

This is unnecessary.
For both `TK_MemberSpecialization` and `TK_DependentNonTemplate`, in `FD->getTemplatedKind()`, we had ensured that `getMemberSpecializationInfo()` or `getInstantiatedFromDecl()` would always return non-null.

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


More information about the cfe-commits mailing list