Commit Graph

83 Commits

Author SHA1 Message Date
Reid Kleckner 7810af0a43 [ms-cxxabi] Emit and install appropriately mangled vbtables
In Itanium, dynamic classes have one vtable with several different
address points for dynamic base classes that can't share vtables.

In the MS C++ ABI, each vbtable that can't be shared gets its own
symbol, similar to how ctor vtables work in Itanium.  However, instead
of mangling the subobject offset into the symbol, the unique portions of
the inheritance path are mangled into the symbol to make it unique.

This patch implements the MSVC 2012 scheme for forming unique vbtable
symbol names.  MSVC 2010 use the same mangling with a different subset
of the path.  Implementing that mangling and possibly others is TODO.

Each vbtable is an array of i32 offsets from the vbptr that points to it
to another virtual base subobject.  The first entry of a vbtable always
points to the base of the current subobject, implying that it is the
same no matter which parent class contains it.

Reviewers: rjmccall

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

llvm-svn: 184309
2013-06-19 15:20:38 +00:00
Reid Kleckner fdf02a7abd Remove unused #include <map>
llvm-svn: 182500
2013-05-22 18:46:02 +00:00
Reid Kleckner 7dafb23232 Use StringMap in MicrosoftMangle to resolve FIXME.
llvm-svn: 182488
2013-05-22 17:16:39 +00:00
David Blaikie 014399c0de Fix clang -Werror build due to -Wreorder violation introduced in r181825
llvm-svn: 181834
2013-05-14 21:31:46 +00:00
Reid Kleckner 369f316ef8 [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!

llvm-svn: 181825
2013-05-14 20:30:42 +00:00
Rafael Espindola 3ae00052cd Cleanup handling of UniqueExternalLinkage.
This patch renames getLinkage to getLinkageInternal. Only code that
needs to handle UniqueExternalLinkage specially should call this.

Linkage, as defined in the c++ standard, is provided by
getFormalLinkage. It maps UniqueExternalLinkage to ExternalLinkage.

Most places in the compiler actually want isExternallyVisible, which
handles UniqueExternalLinkage as internal.

llvm-svn: 181677
2013-05-13 00:12:11 +00:00
Ben Langmuir 3b4c30b7e7 CodeGen for CapturedStmts
EmitCapturedStmt creates a captured struct containing all of the captured
variables, and then emits a call to the outlined function.  This is similar in
principle to EmitBlockLiteral.

GenerateCapturedFunction actually produces the outlined function.  It is based
on GenerateBlockFunction, but is much simpler.  The function type is determined
by the parameters that are in the CapturedDecl.

Some changes have been added to this patch that were reviewed as part of the
serialization patch and moving the parameters to the captured decl.

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

llvm-svn: 181536
2013-05-09 19:17:11 +00:00
Peter Collingbourne 2816c023ea [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

llvm-svn: 180250
2013-04-25 04:25:40 +00:00
Reid Kleckner 5fdaac15ec [ms-cxxabi] Add "$$C" when mangling template arg QualTypes
Credit goes to Timur Iskhodzhanov for finding the problem and solution.

llvm-svn: 179093
2013-04-09 12:47:38 +00:00
Reid Kleckner e7e64d8a7b [ms-cxxabi] Mangle vector types
Summary:
The only vector types a user can pass from MSVC code to clang code are
the ones from *mmintrin.h, so we only have to match the MSVC mangling
for these types.  MSVC mangles the __m128 family of types as tag types,
which we match.  For other vector types, we emit a unique tag type
mangling that won't match anything produced by MSVC.

Reviewers: rjmccall

CC: chandlerc, timurrrr, cfe-commits

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

llvm-svn: 178036
2013-03-26 16:56:59 +00:00
Reid Kleckner 831b71e0b5 [ms-cxxabi] Mangle function pointer template arguments correctly
Reviewers: rjmccall

CC: timurrrr, llvm-commits

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

llvm-svn: 177589
2013-03-20 22:29:42 +00:00
Reid Kleckner 5251886cd8 [ms-cxxabi] Fix assertion on unhandled function template arg types
This code was changed in r158376 to get template argument source info
for better diagnostics, but the current code asserts for any kind of
unsupported template argument before it can issue a diagnostic.  This change
goes back to the Itanium implementation of isTemplate() and puts the argument
index into the diagnostic instead of a source location.

Review URL: http://llvm-reviews.chandlerc.com/D553

llvm-svn: 177471
2013-03-20 01:40:23 +00:00
Timur Iskhodzhanov 57cbe5c790 Better support for constructors with -cxx-abi microsoft, partly fixes PR12784
llvm-svn: 176186
2013-02-27 13:46:31 +00:00
David Blaikie 6adc78e0df Replace TypeLoc llvm::cast support to be well-defined.
The TypeLoc hierarchy used the llvm::cast machinery to perform undefined
behavior by casting pointers/references to TypeLoc objects to derived types
and then using the derived copy constructors (or even returning pointers to
derived types that actually point to the original TypeLoc object).

Some context is in this thread:
http://lists.cs.uiuc.edu/pipermail/llvmdev/2012-December/056804.html
Though it's spread over a few months which can be hard to read in the mail
archive.

llvm-svn: 175462
2013-02-18 22:06:02 +00:00
Timur Iskhodzhanov ee6bc53365 Emit virtual/deleting destructors properly with -cxx-abi microsoft, PR15058
llvm-svn: 175045
2013-02-13 08:37:51 +00:00
Guy Benyei 610541989a Add OpenCL samplers as Clang builtin types and check sampler related restrictions.
llvm-svn: 174601
2013-02-07 10:55:47 +00:00
Guy Benyei 1b4fb3e08b Implement OpenCL event_t as Clang builtin type, including event_t related OpenCL restrictions (OpenCL 1.2 spec 6.9)
llvm-svn: 172973
2013-01-20 12:31:11 +00:00
Guy Benyei d8a08ea98d Re-commit r170428 changes with Linux style file endings.
Add OpenCL images as clang builtin types.

llvm-svn: 170432
2012-12-18 14:38:23 +00:00
Guy Benyei 11169dded0 Revert changes from r170428, as I accidentally changed the line endings of these files to Windows style.
llvm-svn: 170431
2012-12-18 14:30:41 +00:00
Guy Benyei b13abb952a Add OpenCL images as clang builtin types.
llvm-svn: 170428
2012-12-18 12:30:03 +00:00
Benjamin Kramer ea70eb30a0 Pull the Attr iteration parts out of Attr.h, so including DeclBase.h doesn't pull in all the generated Attr code.
Required to pull some functions out of line, but this shouldn't have a perf impact.
No functionality change.

llvm-svn: 169092
2012-12-01 15:09:41 +00:00
Timur Iskhodzhanov 6732d350ef [-cxx-abi microsoft] Also spill the argument-back-references context when mangling templates
llvm-svn: 168862
2012-11-29 08:58:47 +00:00
Timur Iskhodzhanov 09848e709c Fix PR14413 - incorrect mangling of anonymous namespaces with -cxx-abi microsoft
llvm-svn: 168583
2012-11-26 08:55:48 +00:00
Matt Beaumont-Gay c08fa18596 Fix PR14321, a crash when Clang is built with GCC 4.7 at -O1 or greater.
GCC 4.7 reuses stack slots fairly aggressively, which exposes more temporary
lifetime bugs.

No new test, this was caught by the existing CodeGenCXX/mangle-ms-templates.cpp.

llvm-svn: 168124
2012-11-16 01:14:52 +00:00
Nico Weber 3ad723ca2e [ms] Make mangleIntegerLiteral less aware of exact type of the literal.
Integer literal mangling does not actually depend on exact type of the literal.
This will simplify calling mangleIntegerLiteral when literal type is not known,
for example, when sizes or offsets are mangled as integer literals.

Also, call mangleNumber instead of directly printing mangled values of 0/1, to
avoid this knowledge from being in multiple places.

Patch from Evgeny Eltsin!

llvm-svn: 167878
2012-11-13 22:09:44 +00:00
Nico Weber 5ed8a8a06a [ms] Implement int64_t version of mangleNumber() in terms of the APSInt version.
No intended functionality change.

llvm-svn: 167602
2012-11-09 00:05:56 +00:00
Nico Weber 7d37f05a44 [Windows] Fix mangling of number literal '0'
Do this by making the mangleNumber(APSInt) overload look like
the int64_t version. (The latter should probably just delegate
to the former).

Test from Evgeny Eltsin!

llvm-svn: 167599
2012-11-08 23:38:59 +00:00
Douglas Gregor 811db4eac4 Make DiagnosticOptions intrusively reference-counted, and make sure
the various stakeholders bump up the reference count. In particular,
the diagnostics engine now keeps the DiagnosticOptions object alive.

llvm-svn: 166508
2012-10-23 22:26:28 +00:00
Nico Weber 90a415e7ca When mangling an APSInt with the ms abi, make sure to look at all nibbles.
Currently, it's ignored if the number of set bits isn't divisible by 4.

llvm-svn: 165116
2012-10-03 13:39:49 +00:00
Nico Weber 7dfc8be995 While I'm here, resync a %select with the enum definition it selects on.
* nullptr used to be mapped to ERROR, now mapped to nullptr
* integral was missing
* expressions now have their own error message, so they won't reach
  this. Map them to ERROR.

Note that clang usually crashes before emitting this diagnostic anyway
(see PR13984), so this change alone doesn't have an observable effect.
It makes the code more correct though.

llvm-svn: 165095
2012-10-03 06:57:02 +00:00
Nico Weber a682681058 Move expression mangling in the microsoft mangler to its own function.
This matches what's done in ItaniumMangle and makes it a bit easier
to implement mangling for more expressions. Also use the slightly nicer
"not yet implemented" error message from there.

No functionality change (except for the different error message).

llvm-svn: 165093
2012-10-03 06:46:47 +00:00
Nico Weber 1dc7e03047 Replace a default: with an explicit list of cases. No functionality change.
llvm-svn: 165091
2012-10-03 06:12:27 +00:00
Timur Iskhodzhanov 27b6edf839 Fix PR13444 - wrong mangling of "const char * const *" and friends with "-cxx-abi microsoft"
llvm-svn: 163110
2012-09-03 09:08:10 +00:00
Joao Matos e9a3ed4d71 Normalize line endings of r163013 (part 2).
llvm-svn: 163032
2012-08-31 22:18:20 +00:00
Joao Matos dc86f94f62 Improved MSVC __interface support by adding first class support for it, instead of aliasing to "struct" which had some incorrect behaviour. Patch by David Robins.
llvm-svn: 163013
2012-08-31 18:45:21 +00:00
John McCall 64044c3a81 Use cast<> instead of static_cast. Patch by Timur Iskhodzhanov!
llvm-svn: 162683
2012-08-27 18:12:29 +00:00
John McCall 3351dc397b Fix the mangling of function pointers in the MS ABI.
Patch by Timur Iskhodzhanov!

llvm-svn: 162638
2012-08-25 01:12:56 +00:00
Timur Iskhodzhanov 3c80d5aa15 Remove an outdated comment; add one test to compare function pointer and block mangling
llvm-svn: 160783
2012-07-26 13:41:30 +00:00
Timur Iskhodzhanov 25fabdbace Fix PR13389 (Wrong mangling of return type qualifiers with -cxx-abi microsoft)
llvm-svn: 160780
2012-07-26 10:41:15 +00:00
Timur Iskhodzhanov ff7ff3f30b Add a FIXME to revisit the performance of BackRefMap later
llvm-svn: 160709
2012-07-25 08:16:41 +00:00
Timur Iskhodzhanov bf0f663bca Fix PR13207 (Mangling of templates with back references when using -cxx-abi microsoft)
llvm-svn: 160667
2012-07-24 09:37:54 +00:00
Timur Iskhodzhanov c5098ad371 [Windows] Use thiscall as the default calling convention for class methods. PR12785
llvm-svn: 160121
2012-07-12 09:50:54 +00:00
Timur Iskhodzhanov 1b1d630e0c [Windows] Improve mangling of templates when back references are present
llvm-svn: 159234
2012-06-26 22:29:50 +00:00
Timur Iskhodzhanov 9137c399bd [Windows] Fix mangling of repeated types in the presence of bool and function pointers PR13176,PR13177
llvm-svn: 159059
2012-06-23 00:54:17 +00:00
Charles Davis de2e5ed4aa MicrosoftMangle: Fix mangling of integral constant non-type template arguments in a class specialization.
llvm-svn: 159056
2012-06-23 00:27:49 +00:00
Richard Smith 73af5c6dda MS: Mangle rvalue references and nullptr_t, and produce back-references when
appropriate. Patch by João Matos!

llvm-svn: 158895
2012-06-21 02:52:27 +00:00
Kaelyn Uhrain c1244ae6a0 Remove the trailing backslash from the comment to remove the warning about
a multi-line comment, fixing builds with e.g. -Werror=comment enabled.

llvm-svn: 158406
2012-06-13 17:05:13 +00:00
Charles Davis a81618db44 Grab bag of Microsoft Mangler fixes:
- Support mangling virtual function tables (base tables need work on the
  ManglerContext interface).
- Correct mangling of local scopes (i.e. functions and C++ methods).
- Replace every llvm_unreachable() for actually-reachable code with a
  diagnostic.

llvm-svn: 158376
2012-06-13 00:18:14 +00:00
Richard Smith f76568591c PR13047: Fix various abuses of clang::Type in the MS mangler, to make it work
in the presence of type sugar.

llvm-svn: 158184
2012-06-08 00:37:04 +00:00
Benjamin Kramer 6003ad5848 Plug a long standing memory leak in TemplateArgument.
The integral APSInt value is now stored in a decomposed form and the backing
store for large values is allocated via the ASTContext. This way its not
leaked as TemplateArguments are never destructed when they are allocated in
the ASTContext. Since the integral data is immutable it is now shared between
instances, making copying TemplateArguments a trivial operation.

Currently getting the integral data out of a TemplateArgument requires creating
a new APSInt object. This is cheap when the value is small but can be expensive
if it's not. If this turns out to be an issue a more efficient accessor could
be added.

llvm-svn: 158150
2012-06-07 15:09:51 +00:00