Fix mangling of implicit calls to operator-> to only include a single "pt",
authorRichard Smith <richard-llvm@metafoo.co.uk>
Mon, 24 Oct 2016 20:29:40 +0000 (20:29 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Mon, 24 Oct 2016 20:29:40 +0000 (20:29 +0000)
rather than including an extra one for each level of 'operator->()' invoked.

llvm-svn: 285015

clang/lib/AST/ItaniumMangle.cpp
clang/test/CodeGenCXX/mangle.cpp

index db0df36..15eb111 100644 (file)
@@ -3735,7 +3735,10 @@ recurse:
   case Expr::CXXOperatorCallExprClass: {
     const CXXOperatorCallExpr *CE = cast<CXXOperatorCallExpr>(E);
     unsigned NumArgs = CE->getNumArgs();
-    mangleOperatorName(CE->getOperator(), /*Arity=*/NumArgs);
+    // A CXXOperatorCallExpr for OO_Arrow models only semantics, not syntax
+    // (the enclosing MemberExpr covers the syntactic portion).
+    if (CE->getOperator() != OO_Arrow)
+      mangleOperatorName(CE->getOperator(), /*Arity=*/NumArgs);
     // Mangle the arguments.
     for (unsigned i = 0; i != NumArgs; ++i)
       mangleExpression(CE->getArg(i));
index 5d75710..8ae67c4 100644 (file)
@@ -1111,3 +1111,10 @@ void fn(T, __underlying_type(T)) {}
 template void fn<E>(E, __underlying_type(E));
 // CHECK-LABEL: @_ZN6test552fnINS_1EEEEvT_U3eutS2_
 }
+
+namespace test56 {
+  struct A { A *operator->(); int n; } a;
+  template<int N> void f(decltype(a->n + N)) {}
+  // CHECK-LABEL: @_ZN6test561fILi0EEEvDTplptL_ZNS_1aEE1nT_E
+  template void f<0>(int);
+}