[lldb] [clang] [clang-tools-extra] [c++20] P1907R1: Support for generalized non-type template arguments of scalar type. (PR #78041)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Fri Jan 19 08:33:30 PST 2024


================
@@ -6472,7 +6494,20 @@ void CXXNameMangler::mangleValueInTemplateArg(QualType T, const APValue &V,
       Out << "plcvPcad";
       Kind = Offset;
     } else {
-      if (!V.getLValuePath().empty() || V.isLValueOnePastTheEnd()) {
+      // Clang 11 and before mangled an array subject to array-to-pointer decay
+      // as if it were the declaration itself.
+      bool IsArrayToPointerDecayMangledAsDecl = false;
+      if (TopLevel && Ctx.getLangOpts().getClangABICompat() <=
+                          LangOptions::ClangABI::Ver11) {
+        QualType BType = B.getType();
+        IsArrayToPointerDecayMangledAsDecl =
+            BType->isArrayType() && V.getLValuePath().size() == 1 &&
+            V.getLValuePath()[0].getAsArrayIndex() == 0 &&
+            Ctx.hasSimilarType(T, Ctx.getDecayedType(BType));
+      }
+
----------------
AaronBallman wrote:

I'm surprised by the Clang 11 part: I would have expected this patch to only be changing Clang 17 to Clang 18 behavior, right? Should this code be updated for Clang 17 instead of Clang 11?

Also, there's no test coverage for these changes.

https://github.com/llvm/llvm-project/pull/78041


More information about the cfe-commits mailing list