This revision was automatically updated to reflect the committed changes.
Closed by commit rL315236: PR13575: Fix USR mangling for fixed-size arrays 
(authored by jkorous).

Changed prior to commit:
  https://reviews.llvm.org/D38643?vs=118247&id=118257#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D38643

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


Index: cfe/trunk/test/Index/USR/array-type.cpp
===================================================================
--- cfe/trunk/test/Index/USR/array-type.cpp
+++ cfe/trunk/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<class buffer> 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]>(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]>(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]>(char[64]);
Index: cfe/trunk/lib/Index/USRGeneration.cpp
===================================================================
--- cfe/trunk/lib/Index/USRGeneration.cpp
+++ cfe/trunk/lib/Index/USRGeneration.cpp
@@ -816,6 +816,25 @@
       T = VT->getElementType();
       continue;
     }
+    if (const auto *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 auto *const CAT = dyn_cast<ConstantArrayType>(T))
+        Out << CAT->getSize();
+
+      T = AT->getElementType();
+      continue;
+    }
 
     // Unhandled type.
     Out << ' ';


Index: cfe/trunk/test/Index/USR/array-type.cpp
===================================================================
--- cfe/trunk/test/Index/USR/array-type.cpp
+++ cfe/trunk/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<class buffer> 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]>(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]>(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]>(char[64]);
Index: cfe/trunk/lib/Index/USRGeneration.cpp
===================================================================
--- cfe/trunk/lib/Index/USRGeneration.cpp
+++ cfe/trunk/lib/Index/USRGeneration.cpp
@@ -816,6 +816,25 @@
       T = VT->getElementType();
       continue;
     }
+    if (const auto *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 auto *const CAT = dyn_cast<ConstantArrayType>(T))
+        Out << CAT->getSize();
+
+      T = AT->getElementType();
+      continue;
+    }
 
     // Unhandled type.
     Out << ' ';
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to