r315255 - R13575: Fix USR mangling for function pointer types

Jan Korous via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 9 17:35:16 PDT 2017


Author: jkorous
Date: Mon Oct  9 17:35:16 2017
New Revision: 315255

URL: http://llvm.org/viewvc/llvm-project?rev=315255&view=rev
Log:
R13575: Fix USR mangling for function pointer types

Differential Revision: https://reviews.llvm.org/D38707

Added:
    cfe/trunk/test/Index/USR/func-type.cpp
Modified:
    cfe/trunk/lib/Index/USRGeneration.cpp

Modified: cfe/trunk/lib/Index/USRGeneration.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/USRGeneration.cpp?rev=315255&r1=315254&r2=315255&view=diff
==============================================================================
--- cfe/trunk/lib/Index/USRGeneration.cpp (original)
+++ cfe/trunk/lib/Index/USRGeneration.cpp Mon Oct  9 17:35:16 2017
@@ -754,8 +754,12 @@ void USRGenerator::VisitType(QualType T)
     if (const FunctionProtoType *FT = T->getAs<FunctionProtoType>()) {
       Out << 'F';
       VisitType(FT->getReturnType());
-      for (const auto &I : FT->param_types())
+      Out << '(';
+      for (const auto &I : FT->param_types()) {
+        Out << '#';
         VisitType(I);
+      }
+      Out << ')';
       if (FT->isVariadic())
         Out << '.';
       return;

Added: cfe/trunk/test/Index/USR/func-type.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/USR/func-type.cpp?rev=315255&view=auto
==============================================================================
--- cfe/trunk/test/Index/USR/func-type.cpp (added)
+++ cfe/trunk/test/Index/USR/func-type.cpp Mon Oct  9 17:35:16 2017
@@ -0,0 +1,18 @@
+// RUN: c-index-test core -print-source-symbols -- %s | FileCheck %s
+
+// Functions taking function pointer parameters with different signatures should result in unique USRs.
+
+typedef void (*_VoidToVoidPtr_)();
+typedef void (*_IntToVoidPtr_)( int );
+typedef _VoidToVoidPtr_ (*IntTo_VoidToVoidPtr_Ptr)( int );
+typedef _IntToVoidPtr_ (*VoidTo_IntToVoidPtr_Ptr)();
+
+void Func( IntTo_VoidToVoidPtr_Ptr );
+// CHECK: {{[0-9]+}}:6 | function/C | Func | c:@F at Func#*F*Fv()(#I)# |
+void Func( VoidTo_IntToVoidPtr_Ptr );
+// CHECK: {{[0-9]+}}:6 | function/C | Func | c:@F at Func#*F*Fv(#I)()# |
+
+void Func( void (* (*)(int, int))(int, int) );
+// CHECK: {{[0-9]+}}:6 | function/C | Func | c:@F at Func#*F*Fv(#I#I)(#I#I)# |
+void Func( void (* (*)(int, int, int))(int) );
+// CHECK: {{[0-9]+}}:6 | function/C | Func | c:@F at Func#*F*Fv(#I)(#I#I#I)# |




More information about the cfe-commits mailing list