LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 13182 - [Windows] const arrays are not mangled properly
Summary: [Windows] const arrays are not mangled properly
Status: RESOLVED FIXED
Alias: None
Product: clang
Classification: Unclassified
Component: C++ (show other bugs)
Version: unspecified
Hardware: PC Windows NT
: P enhancement
Assignee: Peter Collingbourne
URL:
Keywords:
Depends on:
Blocks: 12477
  Show dependency tree
 
Reported: 2012-06-22 17:42 PDT by Timur Iskhodzhanov
Modified: 2013-04-24 23:31 PDT (History)
7 users (show)

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Timur Iskhodzhanov 2012-06-22 17:42:34 PDT
Here's a test presented as a diff to test/CodeGenCXX/mangle-ms.cpp

the FIXME lines are the unsatisfied checks, NOW is how these variables are mangled today.


diff --git test/CodeGenCXX/mangle-ms.cpp test/CodeGenCXX/mangle-ms.cpp
index 8798a7d..8440d68 100644
--- test/CodeGenCXX/mangle-ms.cpp
+++ test/CodeGenCXX/mangle-ms.cpp
@@ -2,6 +2,11 @@

 // CHECK: @"\01?a@@3HA"
 // CHECK: @"\01?b@N@@3HA"
+// CHECK: @"\01?s1@N@@3PADA"
+// FIXME: @"\01?s2@N@@3QBDB"
+// NOW:   @"\01?s2@N@@3PBDA"
+// FIXME: @"\01?s3@N@@3QBDB"
+// NOW:   @"\01?s3@N@@3PBDA"
 // CHECK: @c
 // CHECK: @"\01?d@foo@@0FB"
 // CHECK: @"\01?e@foo@@1JC"
@@ -18,10 +23,17 @@

 int a;

-namespace N { int b; }
+namespace N {
+  int b;
+  extern char s1[];
+  extern const char s2[];
+  extern const char s3[42];
+}

 static int c;
-int _c(void) {return c;}
+int _c(void) {
+  return N::s1[0] + N::s2[0] + N::s3[0] + c;
+}
 // CHECK: @"\01?_c@@YAHXZ"

 class foo {
Comment 1 Timur Iskhodzhanov 2012-06-22 17:43:47 PDT
I haven't been able to fix this so far and maybe won't be doing that for some time, so feel free to take over.
Comment 2 João Matos 2012-06-22 19:50:43 PDT
Thanks for the heads up.

I'm also not sure when I'll be able to look into this, so if someone else wants to do it, feel free :)
Comment 3 Timur Iskhodzhanov 2012-07-18 09:45:37 PDT
Taking this PR.
Comment 4 Timur Iskhodzhanov 2012-07-23 04:44:31 PDT
One more broken thing:
  extern RGB const color3[5] = {};
should be mangled as
  "\01?color3@@3QAY02$$CBNA"
but currently it is
  "\01?color3@@3PBY02NA"
Comment 5 Timur Iskhodzhanov 2012-09-03 04:17:41 PDT
FTR, most of these problems were fixed by r163110.
The only remaining one is mentioned in comment #4.

I'm un-assigning it from myself as this is not a top issue for me anymore, feel free to take over!
Comment 6 Peter Collingbourne 2013-04-22 01:08:40 PDT
I'm working on a fix for this (and a number of other mangling bugs).
Comment 7 Peter Collingbourne 2013-04-24 23:31:00 PDT
Fixed by r180250.