[all-commits] [llvm/llvm-project] 26a839: [clang][Sema] Fix initialization of `NonTypeTempla...

Alejandro Álvarez Ayllón via All-commits all-commits at lists.llvm.org
Wed Feb 19 07:19:53 PST 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 26a83994176fcdca6e77be4f221a15f561681621
      https://github.com/llvm/llvm-project/commit/26a83994176fcdca6e77be4f221a15f561681621
  Author: Alejandro Álvarez Ayllón <alejandro.alvarez at sonarsource.com>
  Date:   2025-02-19 (Wed, 19 Feb 2025)

  Changed paths:
    M clang/lib/AST/DeclTemplate.cpp
    M clang/lib/Serialization/ASTWriterDecl.cpp
    A clang/test/Modules/malformed-constraint-template-non-type-parm-decl.cpp

  Log Message:
  -----------
  [clang][Sema] Fix initialization of `NonTypeTemplateParmDecl`... (#121768)

...when there are invalid constraints.

When attaching a `TypeConstraint`, in case of error, the trailing
pointer that is supposed to point to the constraint is left
uninitialized.
Sometimes the uninitialized value will be a `nullptr`, but at other
times it will not. If we traverse the AST (for instance, dumping it, or
when writing the BMI), we may get a crash depending on the value that
was left. The serialization may also contain a bogus value.

In this commit, we always initialize the `PlaceholderTypeConstraint`
with `nullptr`, to avoid accessing this uninitialized memory.

This does not affect only modules, but it causes a segfault more
consistently when they are involved.

The test case was reduced from `mp-units`.

---------

Co-authored-by: Erich Keane <ekeane at nvidia.com>



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list