llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

USR mangling is not unique

Open llvmbot opened this issue 14 years ago • 12 comments

Bugzilla Link 13575
Resolution FIXED
Resolved on Oct 09, 2017 17:40
Version 3.1
OS All
Reporter LLVM Bugzilla Contributor
CC @hyp,@DougGregor,@jkorous-apple

Extended Description

The code snippet below defines two different variants of a template function "dummy". However, for both "dummy" variants "clang_getCursorUSR" returns the same name.

//------snip-----------------------------------------

// some traits template <bool b, typename T> struct RestrictTo {};

template struct RestrictTo<true, T> { typedef T Type; };

template <typename T1, typename T2> struct IsSame { static const bool value = false; };

template struct IsSame<T,T> { static const bool value = true; };

// variant1 template typename RestrictTo<IsSame<T,int>::value, void>::Type dummy(const T &) { // ... }

// variant2 template typename RestrictTo::value, void>::Type dummy(const T &) { // ... }

//------snap-----------------------------------------

llvmbot avatar Aug 10 '12 23:08 llvmbot

r315236, r315241 and rr315255 should fix the remaining issues.

jkorous-apple avatar Oct 10 '17 00:10 jkorous-apple

The other problems are still there though.

hyp avatar Aug 23 '17 16:08 hyp

FYI, the original dummy functions have different USRs now.

hyp avatar Aug 23 '17 16:08 hyp

I'll aim for next release.

hyp avatar Aug 23 '17 16:08 hyp

Is there any chance this ever gets fixed?

llvmbot avatar Nov 05 '15 21:11 llvmbot

Is there any chance that this gets fixed some day?

llvmbot avatar Oct 12 '13 23:10 llvmbot

Here's another case in which different types can get the same USR:

typedef void (*FuncPtrA_)(); typedef void (*FuncPtrB_)( int ); typedef FuncPtrA_ (*FuncPtrA)( int ); typedef FuncPtrB_ (*FuncPtrB)(); void Func( FuncPtrA ) {} // c:@F@Func#FFvI# void Func( FuncPtrB ) {} // c:@F@Func#FFvI#

The problem here is that the representation of function pointer types is too terse; there needs to be a terminator after the parameter list to avoid ambiguity.

llvmbot avatar Nov 03 '12 01:11 llvmbot

cloned to rdar://problem/12627498

DougGregor avatar Nov 02 '12 23:11 DougGregor

Here's another case where unique functions don't have unique USRs: when fixed-length arrays are used as template types to specialize a template function. Here's my example:

// c:@FT@>1#Tmystrlwr#&t0.0# template void mystrlwr( buffer &dst ); // c:@F@mystrlwr<# >#&S0_# template <> void mystrlwr<char[16]>( char (&dst)[16] ); // c:@F@mystrlwr<# >#&S0_# template <> void mystrlwr<char[32]>( char (&dst)[32] ); // c:@F@mystrlwr<# >#&S0_# template <> void mystrlwr<char[64]>( char (&dst)[64] );

As you can see, the template type in this case is 'lost' in the USR, so the three template specializations end up with the same USR.

[discussed on the mailing list in this thread: http://lists.cs.uiuc.edu/pipermail/cfe-dev/2012-November/025522.html]

llvmbot avatar Nov 02 '12 22:11 llvmbot

This issue was discussed in the mailing list

http://lists.cs.uiuc.edu/pipermail/cfe-dev/2012-August/023628.html

and identified as a bug by John McCall and Douglas Gregor.

llvmbot avatar Aug 15 '12 03:08 llvmbot

This issue was discussed in the mailing list

http://lists.cs.uiuc.edu/pipermail/cfe-dev/2012-August/023628.html

and identified as a bug by John McCall and Douglas Gregor.

llvmbot avatar Aug 15 '12 03:08 llvmbot

assigned to @hyp

llvmbot avatar Aug 10 '12 23:08 llvmbot