diff options
author | David Majnemer <david.majnemer@gmail.com> | 2015-03-19 21:54:30 +0000 |
---|---|---|
committer | David Majnemer <david.majnemer@gmail.com> | 2015-03-19 21:54:30 +0000 |
commit | a7f8c46439ea05c6e64ba9c6f25d3261521a05d4 (patch) | |
tree | 0a90f468c7c839b9d72fe2ad8502cc0fb66cecbb /clang/test/CodeGenCXX/mangle-ms-abi-examples.cpp | |
parent | 0a93e2db9c14fb7da613ecccf5a82cab8402a9e5 (diff) | |
download | bcm5719-llvm-a7f8c46439ea05c6e64ba9c6f25d3261521a05d4.tar.gz bcm5719-llvm-a7f8c46439ea05c6e64ba9c6f25d3261521a05d4.zip |
MS ABI: Implement the MSVC 2015 scheme for scope disambiguation
consider C++ that looks like:
inline int &f(bool b) {
if (b) {
static int i;
return i;
}
static int i;
return i;
}
Both 'i' variables must have distinct (and stable) names for linkage
purposes. The MSVC 2013 ABI would number the variables using a count of
the number of scopes that have been created. However, the final 'i'
returns to a scope that has already been created leading to a mangling
collision.
MSVC 2015 fixes this by giving the second 'i' the name it would have if
it were declared before the 'if'. However, this results in ABI breakage
because the mangled name, in cases where there was no ambiguity, would
now be different.
We implement the new behavior and only enable it if we are targeting the
MSVC 2015 ABI, otherwise the old behavior will be used.
This fixes PR18131.
llvm-svn: 232766
Diffstat (limited to 'clang/test/CodeGenCXX/mangle-ms-abi-examples.cpp')
-rw-r--r-- | clang/test/CodeGenCXX/mangle-ms-abi-examples.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/clang/test/CodeGenCXX/mangle-ms-abi-examples.cpp b/clang/test/CodeGenCXX/mangle-ms-abi-examples.cpp index d6ff94b6e3b..6b6ad89b434 100644 --- a/clang/test/CodeGenCXX/mangle-ms-abi-examples.cpp +++ b/clang/test/CodeGenCXX/mangle-ms-abi-examples.cpp @@ -1,8 +1,10 @@ -// RUN: %clang_cc1 -fms-extensions -fno-rtti -emit-llvm %s -o - -triple=i386-pc-win32 | FileCheck %s +// RUN: %clang_cc1 -fms-extensions -fno-rtti -emit-llvm %s -o - -triple=i386-pc-win32 -fms-compatibility-version=19.00 | FileCheck %s --check-prefix=CHECK --check-prefix=MSVC2015 +// RUN: %clang_cc1 -fms-extensions -fno-rtti -emit-llvm %s -o - -triple=i386-pc-win32 -fms-compatibility-version=18.00 | FileCheck %s --check-prefix=CHECK --check-prefix=MSVC2013 // CHECK: @"\01??_7B@?1??foo@A@@QAEXH@Z@6B@" = // CHECK: @"\01??_7D@C@?1??foo@@YAXXZ@6B@" = -// CHECK: define {{.*}} @"\01?baz@E@?3??bar@C@?1??foo@@YAXXZ@QAEXXZ@QAEXXZ"( +// MSVC2013: define {{.*}} @"\01?baz@E@?3??bar@C@?1??foo@@YAXXZ@QAEXXZ@QAEXXZ"( +// MSVC2015: define {{.*}} @"\01?baz@E@?1??bar@C@?1??foo@@YAXXZ@QAEXXZ@QAEXXZ"( // Microsoft Visual C++ ABI examples. struct A { |