From 040fa34becf1c197f9f1c570eb5ca0923b345aa0 Mon Sep 17 00:00:00 2001 From: David Majnemer Date: Sun, 5 Oct 2014 06:44:53 +0000 Subject: [PATCH] MS ABI: Use '1' (instead of '0') relative scope discriminators This changes the scope discriminator's behavior to start at '1' instead of '0'. Symbol table diffing, for ABI compatibility testing, kept finding these as false positives. llvm-svn: 219075 --- clang/lib/AST/MicrosoftMangle.cpp | 2 +- clang/test/CodeGenCXX/dllexport.cpp | 4 ++-- clang/test/CodeGenCXX/dllimport.cpp | 2 +- clang/test/CodeGenCXX/mangle-ms-cxx14.cpp | 4 ++-- .../test/CodeGenCXX/microsoft-abi-static-initializers.cpp | 8 ++++---- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/clang/lib/AST/MicrosoftMangle.cpp b/clang/lib/AST/MicrosoftMangle.cpp index d5566e70ca36..780430e8fefc 100644 --- a/clang/lib/AST/MicrosoftMangle.cpp +++ b/clang/lib/AST/MicrosoftMangle.cpp @@ -160,7 +160,7 @@ public: unsigned &discriminator = Uniquifier[ND]; if (!discriminator) discriminator = ++Discriminator[std::make_pair(DC, ND->getIdentifier())]; - disc = discriminator; + disc = discriminator + 1; return true; } diff --git a/clang/test/CodeGenCXX/dllexport.cpp b/clang/test/CodeGenCXX/dllexport.cpp index 3daacf065b32..13bd0a6b3b71 100644 --- a/clang/test/CodeGenCXX/dllexport.cpp +++ b/clang/test/CodeGenCXX/dllexport.cpp @@ -77,8 +77,8 @@ namespace ns { __declspec(dllexport) int ExternalGlobal; } __declspec(dllexport) auto ExternalAutoTypeGlobal = External(); int f(); -// MSC-DAG: @"\01?x@?0??nonInlineStaticLocalsFunc@@YAHXZ@4HA" = internal {{(unnamed_addr )*}}global i32 0 -// MSC-DAG: @"\01?$S1@?0??nonInlineStaticLocalsFunc@@YAHXZ@4IA" = internal {{(unnamed_addr )*}}global i32 0 +// MSC-DAG: @"\01?x@?1??nonInlineStaticLocalsFunc@@YAHXZ@4HA" = internal {{(unnamed_addr )*}}global i32 0 +// MSC-DAG: @"\01?$S1@?1??nonInlineStaticLocalsFunc@@YAHXZ@4IA" = internal {{(unnamed_addr )*}}global i32 0 int __declspec(dllexport) nonInlineStaticLocalsFunc() { static int x = f(); return x++; diff --git a/clang/test/CodeGenCXX/dllimport.cpp b/clang/test/CodeGenCXX/dllimport.cpp index 3ba7f963823f..a0703d6eefa5 100644 --- a/clang/test/CodeGenCXX/dllimport.cpp +++ b/clang/test/CodeGenCXX/dllimport.cpp @@ -95,7 +95,7 @@ inline int __declspec(dllimport) inlineStaticLocalsFunc() { USE(inlineStaticLocalsFunc); // The address of a dllimport global cannot be used in constant initialization. -// M32-DAG: @"\01?arr@?0??initializationFunc@@YAPAHXZ@4QBQAHB" = internal global [1 x i32*] zeroinitializer +// M32-DAG: @"\01?arr@?1??initializationFunc@@YAPAHXZ@4QBQAHB" = internal global [1 x i32*] zeroinitializer // GNU-DAG: @_ZZ18initializationFuncvE3arr = internal global [1 x i32*] zeroinitializer int *initializationFunc() { static int *const arr[] = {&ExternGlobalDecl}; diff --git a/clang/test/CodeGenCXX/mangle-ms-cxx14.cpp b/clang/test/CodeGenCXX/mangle-ms-cxx14.cpp index 03995611d252..c06efe2edee9 100644 --- a/clang/test/CodeGenCXX/mangle-ms-cxx14.cpp +++ b/clang/test/CodeGenCXX/mangle-ms-cxx14.cpp @@ -13,7 +13,7 @@ auto FunctionWithLocalType() { return LocalType{}; } -// CHECK: "\01?ValueFromFunctionWithLocalType@@3ULocalType@?0??FunctionWithLocalType@@YA?A?@@XZ@A" +// CHECK: "\01?ValueFromFunctionWithLocalType@@3ULocalType@?1??FunctionWithLocalType@@YA?A?@@XZ@A" auto ValueFromFunctionWithLocalType = FunctionWithLocalType(); // CHECK: "\01??R@@QBE?A?@@XZ" @@ -22,7 +22,7 @@ auto LambdaWithLocalType = [] { return LocalType{}; }; -// CHECK: "\01?ValueFromLambdaWithLocalType@@3ULocalType@?0???R@@QBE?A?@@XZ@A" +// CHECK: "\01?ValueFromLambdaWithLocalType@@3ULocalType@?1???R@@QBE?A?@@XZ@A" auto ValueFromLambdaWithLocalType = LambdaWithLocalType(); template diff --git a/clang/test/CodeGenCXX/microsoft-abi-static-initializers.cpp b/clang/test/CodeGenCXX/microsoft-abi-static-initializers.cpp index f255ef02a121..76d7e9e19192 100644 --- a/clang/test/CodeGenCXX/microsoft-abi-static-initializers.cpp +++ b/clang/test/CodeGenCXX/microsoft-abi-static-initializers.cpp @@ -52,8 +52,8 @@ void StaticLocal() { } // CHECK-LABEL: define void @"\01?StaticLocal@@YAXXZ"() -// CHECK: load i32* @"\01?$S1@?0??StaticLocal@@YAXXZ@4IA" -// CHECK: store i32 {{.*}}, i32* @"\01?$S1@?0??StaticLocal@@YAXXZ@4IA" +// CHECK: load i32* @"\01?$S1@?1??StaticLocal@@YAXXZ@4IA" +// CHECK: store i32 {{.*}}, i32* @"\01?$S1@?1??StaticLocal@@YAXXZ@4IA" // CHECK: ret void MultipleStatics() { @@ -94,7 +94,7 @@ void MultipleStatics() { static S S35; } // CHECK-LABEL: define void @"\01?MultipleStatics@@YAXXZ"() -// CHECK: load i32* @"\01?$S1@?0??MultipleStatics@@YAXXZ@4IA" +// CHECK: load i32* @"\01?$S1@?1??MultipleStatics@@YAXXZ@4IA" // CHECK: and i32 {{.*}}, 1 // CHECK: and i32 {{.*}}, 2 // CHECK: and i32 {{.*}}, 4 @@ -102,7 +102,7 @@ void MultipleStatics() { // CHECK: and i32 {{.*}}, 16 // ... // CHECK: and i32 {{.*}}, -2147483648 -// CHECK: load i32* @"\01?$S1@?0??MultipleStatics@@YAXXZ@4IA1" +// CHECK: load i32* @"\01?$S1@?1??MultipleStatics@@YAXXZ@4IA1" // CHECK: and i32 {{.*}}, 1 // CHECK: and i32 {{.*}}, 2 // CHECK: and i32 {{.*}}, 4