[clang] extend getCommonSugaredType to merge sugar nodes
authorMatheus Izvekov <mizvekov@gmail.com>
Tue, 19 Jul 2022 09:02:32 +0000 (11:02 +0200)
committerMatheus Izvekov <mizvekov@gmail.com>
Fri, 16 Sep 2022 15:04:10 +0000 (17:04 +0200)
commit00ce271712d407b5347681c36474b80cfb0033d3
tree1379fc7b0461f763465574b65d0d848dbb645a2c
parent6fe8c433bacf91c5d9281636a7a05a2beefdbf2a
[clang] extend getCommonSugaredType to merge sugar nodes

This continues D111283 by extending the getCommonSugaredType
implementation to also merge non-canonical type nodes.

We merge these nodes by going up starting from the canonical
node, calculating their merged properties on the way.

If we reach a pair that is too different, or which we could not
otherwise unify, we bail out and don't try to keep going on to
the next pair, in effect striping out all the remaining top-level
sugar nodes. This avoids mismatching 'companion' nodes, such as
ElaboratedType, so that they don't end up elaborating some other
unrelated thing.

Signed-off-by: Matheus Izvekov <mizvekov@gmail.com>
Differential Revision: https://reviews.llvm.org/D130308
clang/docs/ReleaseNotes.rst
clang/include/clang/AST/ASTContext.h
clang/lib/AST/ASTContext.cpp
clang/lib/Sema/SemaTemplate.cpp
clang/lib/Sema/SemaTemplateDeduction.cpp
clang/test/SemaCXX/sugar-common-types.cpp
clang/test/SemaTemplate/deduction.cpp