Itanium Mangling: Fix handling of <expr-primary> in <template-arg>.
authorJames Y Knight <jyknight@google.com>
Sun, 24 Jan 2021 20:50:15 +0000 (15:50 -0500)
committerJames Y Knight <jyknight@google.com>
Wed, 27 Jan 2021 21:46:52 +0000 (16:46 -0500)
commit8ca33605ff0cfc536f5c6710fb5f6378bf11959a
tree5d166ca892b12b5ccdf1e7912d186d95be11f344
parent9c7aeaebb3ac1b94200b59b111742cb6b8f090c2
Itanium Mangling: Fix handling of <expr-primary> in <template-arg>.

Previously, we were emitting an extraneous X .. E in <template-arg>
around an <expr-primary> if the template argument was constructed from
an expression (rather than an already-evaluated literal value).  In
such a case, we would then e.g. emit 'XLi0EE' instead of 'Li0E'.

We had one special-case for DeclRefExpr expressions, in particular, to
omit them the mangled-name without the surrounding X/E. However,
unfortunately, that special case also triggered for ParmVarDecl (a
subtype of VarDecl), and _incorrectly_ emitted 'L_Z .. E' instead of
the proper 'Xfp_E'.

This change causes mangleExpression itself to be responsible for
emitting X/E around non-primary expressions, which removes the
special-case, and corrects both these problems.

Differential Revision: https://reviews.llvm.org/D95487
clang/lib/AST/ItaniumMangle.cpp
clang/test/CodeGenCXX/clang-abi-compat.cpp
clang/test/CodeGenCXX/mangle-abi-tag.cpp
clang/test/CodeGenCXX/mangle-concept.cpp
clang/test/CodeGenCXX/mangle-template.cpp
clang/test/CodeGenCXX/mangle.cpp
clang/test/CodeGenCXX/matrix-type.cpp
clang/test/CodeGenCXX/microsoft-uuidof-mangling.cpp