[PATCH] D38643: PR13575: Fix USR mangling for fixed-size arrays.

Jan Korous via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 6 16:05:30 PDT 2017


jkorous-apple updated this revision to Diff 118104.
jkorous-apple added a comment.

Ammenended as suggested.


https://reviews.llvm.org/D38643

Files:
  lib/Index/USRGeneration.cpp
  test/Index/USR/array-type.cpp


Index: test/Index/USR/array-type.cpp
===================================================================
--- /dev/null
+++ test/Index/USR/array-type.cpp
@@ -0,0 +1,8 @@
+// RUN: c-index-test core -print-source-symbols -- %s | grep "function(Gen,TS)/C++" | grep foo | cut -s -d "|" -f 4 | uniq | wc -l | grep 3
+
+// Function template specializations differing in array type parameter should have unique USRs.
+
+template<class buffer> void foo(buffer);
+template<> void foo<char[16]>(char[16]);
+template<> void foo<char[32]>(char[32]);
+template<> void foo<char[64]>(char[64]);
Index: lib/Index/USRGeneration.cpp
===================================================================
--- lib/Index/USRGeneration.cpp
+++ lib/Index/USRGeneration.cpp
@@ -816,6 +816,20 @@
       T = VT->getElementType();
       continue;
     }
+    if (const ArrayType *const AT = dyn_cast<ArrayType>(T)) {
+      Out << "{";
+      switch( AT->getSizeModifier() ) {
+        case ArrayType::Static  : Out << "s"; break;
+        case ArrayType::Star    : Out << "*"; break;
+        case ArrayType::Normal  : Out << "n"; break;
+      }
+      if (const ConstantArrayType* const CAT = dyn_cast<ConstantArrayType>(T)) {
+        Out << CAT->getSize();
+      }
+      Out << "}";
+      T = AT->getElementType();
+      continue;
+    }
 
     // Unhandled type.
     Out << ' ';


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D38643.118104.patch
Type: text/x-patch
Size: 1360 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20171006/11651d81/attachment.bin>


More information about the cfe-commits mailing list