diff options
| author | Jan Korous <jkorous@apple.com> | 2017-10-10 00:35:16 +0000 |
|---|---|---|
| committer | Jan Korous <jkorous@apple.com> | 2017-10-10 00:35:16 +0000 |
| commit | e6a0242ebc5f256d4589af4d0b87bee27962f5fe (patch) | |
| tree | 90af53c4c0f0cbcb2c13a8be0876581b6174e1fd | |
| parent | dcb312bdb9616c19f1e58afc9d06b49f81f648e8 (diff) | |
| download | bcm5719-llvm-e6a0242ebc5f256d4589af4d0b87bee27962f5fe.tar.gz bcm5719-llvm-e6a0242ebc5f256d4589af4d0b87bee27962f5fe.zip | |
R13575: Fix USR mangling for function pointer types
Differential Revision: https://reviews.llvm.org/D38707
llvm-svn: 315255
| -rw-r--r-- | clang/lib/Index/USRGeneration.cpp | 6 | ||||
| -rw-r--r-- | clang/test/Index/USR/func-type.cpp | 18 |
2 files changed, 23 insertions, 1 deletions
diff --git a/clang/lib/Index/USRGeneration.cpp b/clang/lib/Index/USRGeneration.cpp index 81e143858e6..3a06554b256 100644 --- a/clang/lib/Index/USRGeneration.cpp +++ b/clang/lib/Index/USRGeneration.cpp @@ -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; diff --git a/clang/test/Index/USR/func-type.cpp b/clang/test/Index/USR/func-type.cpp new file mode 100644 index 00000000000..ff1cd37a7fc --- /dev/null +++ b/clang/test/Index/USR/func-type.cpp @@ -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@Func#*F*Fv()(#I)# | +void Func( VoidTo_IntToVoidPtr_Ptr ); +// CHECK: {{[0-9]+}}:6 | function/C | Func | c:@F@Func#*F*Fv(#I)()# | + +void Func( void (* (*)(int, int))(int, int) ); +// CHECK: {{[0-9]+}}:6 | function/C | Func | c:@F@Func#*F*Fv(#I#I)(#I#I)# | +void Func( void (* (*)(int, int, int))(int) ); +// CHECK: {{[0-9]+}}:6 | function/C | Func | c:@F@Func#*F*Fv(#I)(#I#I#I)# | |

