[clang] [clang][Sema] Fix initialization of `NonTypeTemplateParmDecl`... (PR #121768)

Alejandro Álvarez Ayllón via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 19 06:55:43 PST 2025


================
@@ -2016,17 +2016,17 @@ void ASTDeclWriter::VisitNonTypeTemplateParmDecl(NonTypeTemplateParmDecl *D) {
   // For an expanded parameter pack, record the number of expansion types here
   // so that it's easier for deserialization to allocate the right amount of
   // memory.
-  Expr *TypeConstraint = D->getPlaceholderTypeConstraint();
----------------
alejandro-alvarez-sonarsource wrote:

There is a difference: `D->hasPlaceholderTypeConstraint()` may be true, but `D->getPlaceholderTypeConstraint` may return `nullptr`.
IIUC, before this patch there was a underlying assumption that the former is true if and only if the latter is not `nullptr`.

This is not aligned when there are parsing errors.

See [my comment here](https://github.com/llvm/llvm-project/pull/121768#discussion_r1908541893).

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


More information about the cfe-commits mailing list