From: Jan Korous Date: Mon, 9 Oct 2017 19:51:33 +0000 (+0000) Subject: PR13575: Fix USR mangling for fixed-size arrays X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=21e1fad25b70e1a6cf1d5f61a2d5c39765a92900;p=clang PR13575: Fix USR mangling for fixed-size arrays Differential Revision: https://reviews.llvm.org/D38643 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@315236 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Index/USRGeneration.cpp b/lib/Index/USRGeneration.cpp index 7afbb8bc36..81e143858e 100644 --- a/lib/Index/USRGeneration.cpp +++ b/lib/Index/USRGeneration.cpp @@ -816,6 +816,25 @@ void USRGenerator::VisitType(QualType T) { T = VT->getElementType(); continue; } + if (const auto *const AT = dyn_cast(T)) { + Out << '{'; + switch (AT->getSizeModifier()) { + case ArrayType::Static: + Out << 's'; + break; + case ArrayType::Star: + Out << '*'; + break; + case ArrayType::Normal: + Out << 'n'; + break; + } + if (const auto *const CAT = dyn_cast(T)) + Out << CAT->getSize(); + + T = AT->getElementType(); + continue; + } // Unhandled type. Out << ' '; diff --git a/test/Index/USR/array-type.cpp b/test/Index/USR/array-type.cpp new file mode 100644 index 0000000000..2ebeb7f4a1 --- /dev/null +++ b/test/Index/USR/array-type.cpp @@ -0,0 +1,11 @@ +// RUN: c-index-test core -print-source-symbols -- %s | FileCheck %s + +// Function template specializations differing in array type parameter should have unique USRs. + +template void foo(buffer); +// CHECK: {{[0-9]+}}:17 | function(Gen,TS)/C++ | foo | c:@F@foo<#{n16C>#*C# | __Z3fooIA16_cEvT_ | Decl,RelSpecialization | rel: 1 +template<> void foo(char[16]); +// CHECK: {{[0-9]+}}:17 | function(Gen,TS)/C++ | foo | c:@F@foo<#{n32C>#*C# | __Z3fooIA32_cEvT_ | Decl,RelSpecialization | rel: 1 +template<> void foo(char[32]); +// CHECK: {{[0-9]+}}:17 | function(Gen,TS)/C++ | foo | c:@F@foo<#{n64C>#*C# | __Z3fooIA64_cEvT_ | Decl,RelSpecialization | rel: 1 +template<> void foo(char[64]);