[clang] [Sema] Fix crash in Sema::FindInstantiatedDecl (PR #96509)

Matheus Izvekov via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 8 13:11:06 PDT 2024


Alejandro =?utf-8?q?Álvarez_Ayllón?Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/96509 at github.com>


================
@@ -6300,7 +6300,7 @@ NamedDecl *Sema::FindInstantiatedDecl(SourceLocation Loc, NamedDecl *D,
                   getTrivialTemplateArgumentLoc(UnpackedArg, QualType(), Loc));
           }
           QualType T = CheckTemplateIdType(TemplateName(TD), Loc, Args);
-          if (T.isNull())
+          if (T.isNull() || T->containsErrors())
----------------
mizvekov wrote:

I don't understand the logic of this change: If there is no reason to make `CheckTemplateIdType` fail for more cases, why make this change then?

Usually in error recovery, we want to carry the error information as much as we can, where practical.
In this case, there is the same implementation complexity either way.
This change went in the opposite direction: We are bailing out earlier for more cases, and we have no reason for it.

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


More information about the cfe-commits mailing list