]> granicus.if.org Git - clang/commit
MS ABI: Implement the MSVC 2015 scheme for scope disambiguation
authorDavid Majnemer <david.majnemer@gmail.com>
Thu, 19 Mar 2015 21:54:30 +0000 (21:54 +0000)
committerDavid Majnemer <david.majnemer@gmail.com>
Thu, 19 Mar 2015 21:54:30 +0000 (21:54 +0000)
commitb2102bd391bcf0bd1f1b8ab33ad1551642d61308
treed74d66bb6471de88072211b333f4a2f49b8f1278
parent6520dff452cf886a6695e73d0a7d364067e63c8b
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@232766 91177308-0d34-0410-b5e6-96231b3b80d8
include/clang/Parse/Parser.h
include/clang/Sema/Scope.h
include/clang/Sema/Sema.h
lib/Parse/ParseStmt.cpp
lib/Sema/Scope.cpp
lib/Sema/SemaDecl.cpp
test/CodeGenCXX/mangle-ms-abi-examples.cpp
test/CodeGenCXX/mangle-ms-cxx11.cpp
test/CodeGenCXX/mangle-ms-cxx14.cpp