[PATCH] MS local statics mangling: don't double-increment mangling number for switches
Hans Wennborg
hans at chromium.org
Mon Jun 16 14:26:10 PDT 2014
Hi majnemer,
It seems we were double-incrementing the mangling number when entering a switch.
http://reviews.llvm.org/D4165
Files:
lib/Parse/ParseStmt.cpp
test/CodeGenCXX/microsoft-abi-static-initializers.cpp
Index: lib/Parse/ParseStmt.cpp
===================================================================
--- lib/Parse/ParseStmt.cpp
+++ lib/Parse/ParseStmt.cpp
@@ -1233,6 +1233,11 @@
getCurScope()->AddFlags(Scope::BreakScope);
ParseScope InnerScope(this, Scope::DeclScope, C99orCXX, Tok.is(tok::l_brace));
+ // We have incremented the mangling number for the SwitchScope and the
+ // InnerScope, which is one too many.
+ if (C99orCXX)
+ getCurScope()->decrementMSLocalManglingNumber();
+
// Read the body statement.
StmtResult Body(ParseStatement(TrailingElseLoc));
Index: test/CodeGenCXX/microsoft-abi-static-initializers.cpp
===================================================================
--- test/CodeGenCXX/microsoft-abi-static-initializers.cpp
+++ test/CodeGenCXX/microsoft-abi-static-initializers.cpp
@@ -162,12 +162,33 @@
}
};
+inline int switch_test(int x) {
+ // CHECK-LABEL: define linkonce_odr i32 @"\01?switch_test@@YAHH at Z"(i32 %x)
+ switch (x) {
+ static int a;
+ // CHECK: @"\01?a@?3??switch_test@@YAHH at Z@4HA"
+ case 0:
+ a++;
+ return 1;
+ case 1:
+ static int b;
+ // CHECK: @"\01?b@?3??switch_test@@YAHH at Z@4HA"
+ return b++;
+ case 2: {
+ static int c;
+ // CHECK: @"\01?c@?4??switch_test@@YAHH at Z@4HA"
+ return b + c++;
+ }
+ };
+}
+
void force_usage() {
UnreachableStatic();
getS();
(void)B<int>::foo; // (void) - force usage
enum_in_function();
(void)&T::enum_in_struct;
+ switch_test(1);
}
// CHECK: define linkonce_odr void @"\01??__Efoo@?$B at H@@2VA@@A at YAXXZ"()
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D4165.10459.patch
Type: text/x-patch
Size: 1592 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140616/3afa3c04/attachment.bin>
More information about the cfe-commits
mailing list