[Serialization] Handle uninitialized type constraintsllvmorg-19.1.3
commitab51eccf88f5321e7c60591c5546b254b6afab99
authorFlorian Albrechtskirchinger <falbrechtskirchinger@gmail.com>
Mon, 21 Oct 2024 10:24:58 +0000 (21 12:24 +0200)
committerTobias Hieta <tobias@hieta.se>
Tue, 29 Oct 2024 10:09:39 +0000 (29 11:09 +0100)
tree42e8016933367b77284d42bfa3057f2fbc42ab05
parente541aa5ff994a370bacb9b039f70efb0672c4a1b
[Serialization] Handle uninitialized type constraints

The ASTWriter currently assumes template type constraints to be
initialized ((bool)getTypeConstraint() == hasTypeConstraint()). Issues
#99036 and #109354 identified a scenario where this assertion is
violated.

This patch removes the assumption and adds another boolean to the
serialization, to explicitly encode whether the type constraint has been
initialized.

The same issue was incidentally fixed on the main branch by #111179.
This solution avoids backporting #111179 and its dependencies.
clang/lib/Serialization/ASTReaderDecl.cpp
clang/lib/Serialization/ASTWriterDecl.cpp
clang/test/PCH/cxx2a-constraints-crash.cpp