Commit Graph

51 Commits

Author SHA1 Message Date
Will Wilson 63c7eb807c MS ABI: Correctly mangle CV qualifiers from typedefs
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@221344 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-05 13:54:21 +00:00
Reid Kleckner cb348a9ab7 Add frontend support for __vectorcall
Wire it through everywhere we have support for fastcall, essentially.

This allows us to parse the MSVC "14" CTP headers, but we will
miscompile them because LLVM doesn't support __vectorcall yet.

Reviewed By: Aaron Ballman

Differential Revision: http://reviews.llvm.org/D5808

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@220573 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-24 17:42:17 +00:00
David Majnemer 1425f1b3ec MS ABI: Reorganize some tests
Move some c++11 specific tests to mangle-ms-cxx11


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@202790 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-04 05:47:41 +00:00
David Majnemer e4f0f4ab79 MS ABI: Refactor extended qualifiers
Extended qualifiers can appear in many places, refactor the code so it's
more reusable.  Add tests in areas where we've increased compatibility.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@201574 91177308-0d34-0410-b5e6-96231b3b80d8
2014-02-18 14:20:10 +00:00
David Majnemer 8bd69ae743 MS ABI: Add support for mangling __restrict
Pointer types in the MSVC ABI are a bit awkward, the width of the
pointer is considered a kind of CVR qualifier.

Restrict is handled similarly to const and volatile but is mangled after
the pointer width qualifier.

This fixes PR18880.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@201569 91177308-0d34-0410-b5e6-96231b3b80d8
2014-02-18 12:58:35 +00:00
Hans Wennborg 11b1b8ab36 Remove the -cxx-abi command-line flag.
This makes the C++ ABI depend entirely on the target: MS ABI for -win32 triples,
Itanium otherwise. It's no longer possible to do weird combinations.

To be able to run a test with a specific ABI without constraining it to a
specific triple, new substitutions are added to lit: %itanium_abi_triple and
%ms_abi_triple can be used to get the current target triple adjusted to the
desired ABI. For example, if the test suite is running with the i686-pc-win32
target, %itanium_abi_triple will expand to i686-pc-mingw32.

Differential Revision: http://llvm-reviews.chandlerc.com/D2545

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@199250 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-14 19:35:09 +00:00
David Majnemer 7802756e7c Revert "[-cxx-abi microsoft] Mangle reference temporaries"
This reverts commit r197184.

Richard Smith brings up some good points, a proper implementation will
require us to mangle unnameable entities compatibly with MSVC.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@197192 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-13 00:39:38 +00:00
David Majnemer 8f9f0c367a [-cxx-abi microsoft] Mangle reference temporaries
They are mangled the same as normal references, nothing special is going
on here.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@197184 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-12 23:12:01 +00:00
David Majnemer 4198db23b9 [-cxx-abi microsoft] Properly mangle enums
While testing our ability to mangle large constants (PR18175), I
incidentally discovered that we did not properly mangle enums correctly.

Previously, we would append the width of the enum in bytes after the
type-tag differentiator.

This would mean "enum : short" would be mangled as 'W2' while "enum :
char" would be mangled as 'W1'.  Upon testing this with several versions
of MSVC, I found that this did not match their behavior: they always use
'W4'.

N.B.  Quick testing uncovered that undname allows different numbers to
follow the 'W' in the following way:

'W0' -> "enum char"
'W1' -> "enum unsigned char"
'W2' -> "enum short"
'W3' -> "enum unsigned short"
'W4' -> "enum"
'W5' -> "enum unsigned int"
'W6' -> "enum long"
'W7' -> "enum unsigned long"

However this scheme appears abandoned, I cannot get MSVC to trigger it.
Furthermore, it's incomplete: it doesn't handle "bool" or "long long".


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@196752 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-09 04:28:34 +00:00
David Majnemer 3175b60a55 [-cxx-abi microsoft] Create backrefs for <unnamed-type-`id'>
It wasn't possible for an anonymous type to show up inside of function arguments.
However, decltype (which MSVC added support for in 2010) makes this
possible.  Further, backrefs to these anonymous types can now be formed.

This fixes PR18022.

N.B. We do not, and very likely _will not_, support MSVC's bug where
subsequent typedefs of anonymous types leak into the linkage name; this
is a gross violation of the ABI.  A warning should be introduced to
inform our users of this particular shortcoming.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@195669 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-25 17:50:19 +00:00
Reid Kleckner d1a32c328b [ms-cxxabi] Fix the calling convention for operator new in records
Summary:
Operator new, new[], delete, and delete[] are all implicitly static when
declared inside a record.  CXXMethodDecl already knows this, but we need
to account for that before we pick the calling convention for the
function type.

Fixes PR17371.

Reviewers: rsmith

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D1761

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@192150 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-08 00:58:57 +00:00
David Majnemer aa82461f69 Revert "Revert "[-cxx-abi microsoft] Mangle local TagDecls appropriately""
This reverts commit r190895 which reverted r190892.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190904 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-17 23:57:10 +00:00
David Majnemer 1f7fd68131 Revert "[-cxx-abi microsoft] Mangle local TagDecls appropriately"
This reverts commit r190892.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190895 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-17 22:45:28 +00:00
David Majnemer 0754047827 [-cxx-abi microsoft] Mangle local TagDecls appropriately
Summary:
When selecting a mangling for an anonymous tag type:
- We should first try it's typedef'd name.
- If that doesn't work, we should mangle in the name of the declarator
  that specified it as a declaration specifier.
- If that doesn't work, fall back to a static mangling of
  <unnamed-type>.

This should make our anonymous type mangling compatible.

This partially fixes PR16994; we would need to have an implementation of
scope numbering to get it right (a separate issue).

Reviewers: rnk, rsmith, rjmccall, cdavis5x

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D1540

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190892 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-17 22:21:27 +00:00
David Majnemer 978c5e0c23 [-cxx-abi microsoft] Mangle user defined entry points properly
Summary:
Functions named "main", "wmain", "WinMain", "wWinMain", and "DllMain"
are never mangled regardless of linkage, even when compiling for kernel
mode.
Depends on D1655

Reviewers: timurrrr, pcc, rnk, whunt

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D1670

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190675 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-13 09:40:55 +00:00
David Majnemer cab7dad9eb [-cxx-abi microsoft] Mangle declarations inside extern "C"
Summary:
This is a first step to getting extern "C" working properly inside
clang.  There are a number of quirks but mangling declarations inside
such a function are a good first step.

Reviewers: timurrrr, pcc, cdavis5x

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D1655

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190671 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-13 09:03:14 +00:00
David Majnemer 167b774cc5 CHECK -> CHECK-DAG
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190670 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-13 08:59:19 +00:00
David Majnemer afc1ea17c7 Add back a test that was removed in r188450
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@188453 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-15 08:34:07 +00:00
David Majnemer 1c7a4094af [-cxx-abi microsoft] Mangle member pointers better
Summary:
There were several things going wrong:
- We mangled in useless qualifiers like "volatile void" return types.
- We didn't propagate 64-bit pointer markers sufficiently.
- We mangled qualifiers belonging to the pointee incorrectly.

This fixes PR16844 and PR16848.

Reviewers: rnk, whunt

Reviewed By: rnk

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D1353

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@188450 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-15 08:13:23 +00:00
David Majnemer c0e64f3d29 [ms-cxxabi] Properly mangle member pointers
There were three things missing from the original implementation:

- We would omit the 'E' qualifier for members int 64-bit mode.
- We would not exmaine the qualifiers in 'IsMember' mode.
- We didn't generate the correct backref to the base class.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@187753 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-05 22:43:06 +00:00
Reid Kleckner d6a08d16a0 [ms-cxxabi] Mangle in an implicit 'E' for certain types on win64
Most of the complexity of this patch is figuring out which types get the
qualifier and which don't.  If we implement __ptr32/64, then we should
check the qualifier instead of assuming all pointers are 64-bit.

This fixes PR13792.

Patch by Warren Hunt!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181825 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-14 20:30:42 +00:00
Peter Collingbourne b70d1c32ca [ms-cxxabi] Fix a number of bugs in the mangler.
This includes the following fixes:
 - Implement 4 subtly different variants of qualifier mangling and use them
   in what I believe are the right places.
 - Fix handling of array types.  Previously we were always decaying them,
   which is wrong if the type appears as a template argument, pointee,
   referent etc.
Fixes PR13182.

Differential Revision: http://llvm-reviews.chandlerc.com/D709

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@180250 91177308-0d34-0410-b5e6-96231b3b80d8
2013-04-25 04:25:40 +00:00
Timur Iskhodzhanov 79b7cc5965 Fix PR14413 - incorrect mangling of anonymous namespaces with -cxx-abi microsoft
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@168583 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-26 08:55:48 +00:00
Aaron Ballman 82bfa19fe3 Allowing individual targets to determine whether a given calling convention is allowed or ignored with warning. This allows for correct name mangling for x64 targets on Windows, which in turn allows for linking against the Win32 APIs.
Fixes PR13782

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165015 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-02 14:26:08 +00:00
Timur Iskhodzhanov a04ca5c4e0 Fix PR13444 - wrong mangling of "const char * const *" and friends with "-cxx-abi microsoft"
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163110 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-03 09:08:10 +00:00
John McCall 2612e9f1d0 Fix the mangling of function pointers in the MS ABI.
Patch by Timur Iskhodzhanov!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162638 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-25 01:12:56 +00:00
Timur Iskhodzhanov bae11d8f82 Remove an outdated comment; add one test to compare function pointer and block mangling
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160783 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-26 13:41:30 +00:00
Timur Iskhodzhanov 1cc9be04bd Follow-up: fix the quotes
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160626 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-23 09:43:03 +00:00
Timur Iskhodzhanov a5427447a3 Replace wrong CHECK array mangling expectations with correct CHECK-NOT+FIXME (PR13182)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160625 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-23 09:32:54 +00:00
Timur Iskhodzhanov df438046c0 Add a few more test cases for the -cxx-abi microsoft mangler. Some of them were broken recently
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159248 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-27 01:38:25 +00:00
Richard Smith 06e767d670 MS: Mangle rvalue references and nullptr_t, and produce back-references when
appropriate. Patch by João Matos!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158895 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-21 02:52:27 +00:00
Richard Smith c0838d2acb PR13047: Fix various abuses of clang::Type in the MS mangler, to make it work
in the presence of type sugar.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158184 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-08 00:37:04 +00:00
Richard Smith bd1d18ecc4 PR13022: cope with parenthesized function types in MS name mangling.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@157959 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-04 22:46:59 +00:00
John McCall e2b45e2a43 Refactor the C++ ABI code a little bit to take advantage of
what I'm going to treat as basically universal properties of
array-cookie code.  Implement MS array cookies on top of that.
Based on a patch by Timur Iskhodzhanov!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155886 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-01 05:23:51 +00:00
John McCall 3a8ac07956 When mangling a synthetic function declaration, we might not have
type-source information for its parameters.  Don't crash when
mangling them in the MS C++ ABI.  Patch by Timur Iskhodzhanov!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155879 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-01 02:33:44 +00:00
Michael J. Spencer 50118da99d Add Microsoft mangling of constructors and destructors. Patch by Dmitry!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@145581 91177308-0d34-0410-b5e6-96231b3b80d8
2011-12-01 09:55:00 +00:00
Charles Davis ee743f9038 Use the right calling convention when mangling names in the Microsoft C++
mangler. Now member functions and pointers thereof have their calling
convention mangled as __thiscall if they have the default CC (even though,
they technically still have the __cdecl CC).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@118598 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-09 18:04:24 +00:00
Charles Davis 4d254836f4 Mangle Objective-C pointers and block pointers in the Microsoft C++ Mangler.
ObjC pointers were easy enough (as far as the ABI is concerned, they're
just pointers to structs), but I had to invent a new mangling for block
pointers. This is particularly worrying with the Microsoft ABI, because
it is a vendor-specific ABI; extending it could come back to bite us
later when MS extends it on their own (and you know they will).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@107572 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-03 16:56:59 +00:00
Charles Davis 08778269cf Fix mangling of array dimensions in the Microsoft C++ Mangler.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@107568 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-03 08:15:16 +00:00
Charles Davis cd712cb571 Mangle member pointer types in the Microsoft C++ Mangler.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@107567 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-03 08:01:32 +00:00
Charles Davis 1139da148e Fix mangling of function pointers in the Microsoft C++ Mangler.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@107564 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-03 05:53:41 +00:00
Charles Davis 4f0a3376a5 Fix mangling of array parameters for functions in the Microsoft C++ Mangler.
Only actual functions get mangled correctly; I don't know how to fix it for
function pointers yet. Thanks to John McCall for the hint.

Also, mangle anonymous tag types. I don't have a suitable testcase yet; I have
a feeling that that's going to need support for static locals, and I haven't
figured out exactly how MSVC's scheme for mangling those works.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@107561 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-03 02:41:45 +00:00
Charles Davis 0b8fe8c68e Mangle arrays in the Microsoft C++ Mangler. It's not quite finished (it
doesn't mangle array parameters right), but I think that should be fixed
in Sema (Doug, John, what do you think?).

Also, stub out the remaining mangleType() routines.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@107264 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-30 08:09:57 +00:00
Charles Davis 3a0d41d291 Mangle pointer and (lvalue) reference types in the Microsoft C++ Mangler.
Also, fix mangling of throw specs. Turns out MSVC totally ignores throw
specs when mangling names.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106937 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-26 03:50:05 +00:00
Charles Davis c62458f6ae Mangle tag types (unions, structs, classes, enums) in the Microsoft C++ Mangler.
Also, test that static members with default visibility in a struct have the
right mangling.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106276 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-18 07:51:00 +00:00
Charles Davis 21e2a7e8d3 Mangle operator names in the Microsoft C++ Mangler.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106211 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-17 06:47:31 +00:00
Charles Davis 65161d17cb Start mangling function types in the Microsoft C++ Mangler.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106081 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-16 05:33:16 +00:00
Charles Davis b021f8bd44 Microsoft C++ Mangler:
- Mangle qualifiers.
- Start mangling variables' types into the name. A variable declared with a
  builtin type should now mangle properly.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@105931 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-14 05:29:01 +00:00
Charles Davis 570d2763bc Microsoft C++ Mangler:
- Don't mangle static variables at global scope.
- Add support for mangling builtin types. This will be used later.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@105881 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-12 08:11:16 +00:00
Charles Davis 971154db24 When mangling for the Microsoft C++ ABI, mangle variables in the global
namespace, too.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@105809 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-11 04:25:47 +00:00