Skip to content

Commit 2436254

Browse files
committed
R13575: Fix USR mangling for function pointer types
rdar://problem/12627498 Differential Revision: https://reviews.llvm.org/D38707 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@315255 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 167a435 commit 2436254

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

lib/Index/USRGeneration.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -753,8 +753,12 @@ void USRGenerator::VisitType(QualType T) {
753753
if (const FunctionProtoType *FT = T->getAs<FunctionProtoType>()) {
754754
Out << 'F';
755755
VisitType(FT->getReturnType());
756-
for (const auto &I : FT->param_types())
756+
Out << '(';
757+
for (const auto &I : FT->param_types()) {
758+
Out << '#';
757759
VisitType(I);
760+
}
761+
Out << ')';
758762
if (FT->isVariadic())
759763
Out << '.';
760764
return;

test/Index/USR/func-type.cpp

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// RUN: c-index-test core -print-source-symbols -- %s | FileCheck %s
2+
3+
// Functions taking function pointer parameters with different signatures should result in unique USRs.
4+
5+
typedef void (*_VoidToVoidPtr_)();
6+
typedef void (*_IntToVoidPtr_)( int );
7+
typedef _VoidToVoidPtr_ (*IntTo_VoidToVoidPtr_Ptr)( int );
8+
typedef _IntToVoidPtr_ (*VoidTo_IntToVoidPtr_Ptr)();
9+
10+
void Func( IntTo_VoidToVoidPtr_Ptr );
11+
// CHECK: {{[0-9]+}}:6 | function/C | Func | c:@F@Func#*F*Fv()(#I)# |
12+
void Func( VoidTo_IntToVoidPtr_Ptr );
13+
// CHECK: {{[0-9]+}}:6 | function/C | Func | c:@F@Func#*F*Fv(#I)()# |
14+
15+
void Func( void (* (*)(int, int))(int, int) );
16+
// CHECK: {{[0-9]+}}:6 | function/C | Func | c:@F@Func#*F*Fv(#I#I)(#I#I)# |
17+
void Func( void (* (*)(int, int, int))(int) );
18+
// CHECK: {{[0-9]+}}:6 | function/C | Func | c:@F@Func#*F*Fv(#I)(#I#I#I)# |

0 commit comments

Comments
 (0)