[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>
Thu, 8 Sep 2022 17:17:53 +0000 (19:17 +0200)
commit16e5d6d7f98f1119aab3d10ec4f9e59b5aacd359
treecf443939f1047d89f9c084ed8477251f47b3caba
parentd42122cd5db021e6b14a90a98ad1dd09412efb4c
[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.

Depends on D111509

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