summaryrefslogtreecommitdiffstats
path: root/clang/test/CodeGenCXX/microsoft-abi-member-pointers.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [MS] Fix constexpr data member pointer conversionsReid Kleckner2019-10-291-0/+27
| | | | | | | | | | | | | | | Constexpr data member conversions work by starting with the class that originally introduced the field, and converting from there to the type that the user desires. Before this change, Clang was using the inheritance model from the final destination class type instead of the model from the class that originally introduced the field. To fix this, find the relevant FieldDecl and take its parent class instead of using the member pointer type the user provided. Indirect field decls require some special handling to find the parent class. Fixes PR43803
* IR: print value numbers for unnamed function argumentsTim Northover2019-08-031-3/+3
| | | | | | | | | | For consistency with normal instructions and clarity when reading IR, it's best to print the %0, %1, ... names of function arguments in definitions. Also modifies the parser to accept IR in that form for obvious reasons. llvm-svn: 367755
* [FileCheck] Add -allow-deprecated-dag-overlap to failing clang testsJoel E. Denny2018-07-111-1/+1
| | | | | | | | | | See https://reviews.llvm.org/D47106 for details. Reviewed By: probinson Differential Revision: https://reviews.llvm.org/D47172 llvm-svn: 336844
* Fix null MSInheritanceAttr deref in CXXRecordDecl::getMSInheritanceModel()Reid Kleckner2018-05-311-0/+118
| | | | | | | | | | | | | | Ensure latest MPT decl has a MSInheritanceAttr when instantiating templates, to avoid null MSInheritanceAttr deref in CXXRecordDecl::getMSInheritanceModel(). See PR#37399 for repo / details. Patch by Andrew Rogers! Differential Revision: https://reviews.llvm.org/D46664 llvm-svn: 333680
* [MS] Don't escape MS C++ names with \01Reid Kleckner2018-03-161-81/+81
| | | | | | | It is not needed after LLVM r327734. Now it will be easier to copy-paste IR symbol names from Clang. llvm-svn: 327738
* Bring r325915 back.Rafael Espindola2018-02-231-51/+51
| | | | | | | | | | | | | | | The tests that failed on a windows host have been fixed. Original message: Start setting dso_local for COFF. With this there are still some GVs where we don't set dso_local because setGVProperties is never called. I intend to fix that in followup commits. This is just the bare minimum to teach shouldAssumeDSOLocal what it should do for COFF. llvm-svn: 325940
* Revert "Start setting dso_local for COFF."Rafael Espindola2018-02-231-51/+51
| | | | | | | | This reverts commit r325915. It will take some time to fix the failures on a windows host. llvm-svn: 325929
* Start setting dso_local for COFF.Rafael Espindola2018-02-231-51/+51
| | | | | | | | | With this there are still some GVs where we don't set dso_local because setGVProperties is never called. I intend to fix that in followup commits. This is just the bare minimum to teach shouldAssumeDSOLocal what it should do for COFF. llvm-svn: 325915
* [MS ABI] Allow a member pointers' converted type to changeDavid Majnemer2016-01-261-4/+17
| | | | | | | | | | | | | | | | | | | | | | | | Member pointers in the MS ABI are tricky for a variety of reasons. The size of a member pointer is indeterminate until the program reaches a point where the representation is required to be known. However, *pointers* to member pointers may exist without knowing the pointee type's representation. In these cases, we synthesize an opaque LLVM type for the pointee type. However, we can be in a situation where the underlying member pointer's representation became known mid-way through the program. To account for this, we attempted to manicure CodeGen's type-cache so that we can replace the opaque member pointer type with the real deal while leaving the pointer types unperturbed. This, unfortunately, is a problematic approach to take as we will violate CodeGen's invariants. These violations are mostly harmless but let's do the right thing instead: invalidate the type-cache if a member pointer's LLVM representation changes. This fixes PR26313. llvm-svn: 258839
* [MS ABI] Select an inheritance model in template argumentsDavid Majnemer2015-09-111-0/+11
| | | | | | | | | | | | We used to only select an inheritance model if the pointer to member was nullptr. Instead, select a model regardless of the member pointer's value. N.B. This bug was exposed by making member pointers report true for isIncompleteType but has been latent since the member pointer scheme's inception. llvm-svn: 247464
* [MS ABI] Select a pointer to member representation more oftenDavid Majnemer2015-09-101-0/+16
| | | | | | | | | Given a reference to a pointer to member whose class's inheritance model is unspecified, make sure we come up with an inheritance model in plausible places. One place we were missing involved LValue to RValue conversion, another involved unary type traits. llvm-svn: 247248
* [MS ABI] Don't crash on references to pointers to members in argsDavid Majnemer2015-09-091-0/+6
| | | | | | | | | | | | | We know that a reference can always be dereferenced. However, we don't always know the number of bytes if the reference's pointee type is incomplete. This case was correctly handled but we didn't consider the case where the type is complete but we cannot calculate its size for ABI specific reasons. In this specific case, a member pointer's size is available only under certain conditions. This fixes PR24703. llvm-svn: 247188
* [MSVC] Crash fix: assigning of overloaded member function pointer caused ↵Alexey Bataev2015-08-101-0/+17
| | | | | | | | | assertion Original class was not marked with inheritance attribute and it causes a crash on codegen. Differential Revision: http://reviews.llvm.org/D11828 llvm-svn: 244428
* [MS ABI] Rework member pointer conversionDavid Majnemer2015-06-231-3/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Member pointers in the MS ABI are made complicated due to the following: - Virtual methods in the most derived class (MDC) might live in a vftable in a virtual base. - There are four different representations of member pointer: single inheritance, multiple inheritance, virtual inheritance and the "most general" representation. - Bases might have a *more* general representation than classes which derived from them, a most surprising result. We believed that we could treat all member pointers as-if they were a degenerate case of the multiple inheritance model. This fell apart once we realized that implementing standard member pointers using this ABI requires referencing members with a non-zero vbindex. On a bright note, all but the virtual inheritance model operate rather similarly. The virtual inheritance member pointer representation awkwardly requires a virtual base adjustment in order to refer to entities in the MDC. However, the first virtual base might be quite far from the start of the virtual base. This means that we must add a negative non-virtual displacement. However, things get even more complicated. The most general representation interprets vbindex zero differently from the virtual inheritance model: it doesn't reference the vbtable at all. It turns out that this complexity can increase for quite some time: consider a derived to base conversion from the most general model to the multiple inheritance model... To manage this complexity we introduce a concept of "normalized" member pointer which allows us to treat all three models as the most general model. Then we try to figure out how to map this generalized member pointer onto the destination member pointer model. I've done my best to furnish the code with comments explaining why each adjustment is performed. This fixes PR23878. llvm-svn: 240384
* Forgot to update to a test in r240043David Majnemer2015-06-181-2/+2
| | | | llvm-svn: 240049
* [MS ABI] Initialize "most general" member pointers which don't point at a vbaseDavid Majnemer2015-06-181-1/+1
| | | | | | | | | | The most general model has fields for the vbptr offset and the vbindex. Don't initialize the vbptr offset if the vbindex is 0: we aren't referencing an entity from a vbase. Getting this wrong can make member pointer equality fail. llvm-svn: 240043
* [MS ABI] Lock-in the derived memptr rep. for base-to-derived conversionsDavid Majnemer2015-06-121-0/+11
| | | | | | | | | We would get this right in the case where an explicit cast was formed but not when we were performing an implicit conversion. This fixes PR23828. llvm-svn: 239625
* [MS ABI] Fix the preferred alignment of member pointersDavid Majnemer2015-04-241-29/+29
| | | | | | | Member pointers in the MS ABI have different alignment depending on whether they were created on the stack or live in a record. llvm-svn: 235681
* [opaque pointer types] Explicit non-pointer type for call expressionsDavid Blaikie2015-04-161-1/+1
| | | | | | (migration for recent LLVM change to textual IR for calls) llvm-svn: 235147
* Update Clang tests to handle explicitly typed load changes in LLVM.David Blaikie2015-02-271-25/+25
| | | | llvm-svn: 230795
* Update Clang tests to handle explicitly typed gep changes in LLVM.David Blaikie2015-02-271-15/+15
| | | | llvm-svn: 230783
* MS ABI: Virtual member pointer thunks should be in COMDAT groupsDavid Majnemer2015-01-211-1/+1
| | | | | | | They can be emitted by multiple translation units and thus belong in a COMDAT group. llvm-svn: 226630
* MS ABI: Add another test for PR20017David Majnemer2014-12-091-0/+10
| | | | llvm-svn: 223733
* MS ABI: Emit more canonical vbptr stores and loadsReid Kleckner2014-10-221-15/+15
| | | | | | | | This eliminates some i8* GEPs and makes the IR that clang emits a bit more canonical. More work is needed for vftables, but that isn't a clear win so I plan to send it for review. llvm-svn: 220398
* MS ABI: Don't ICE for pointers to pointers to members of incomplete classesDavid Majnemer2014-09-181-6/+16
| | | | | | | | | | | | | | | | | | | CodeGen would try to come up with an LLVM IR type for a pointer to member type on the way to forming an LLVM IR type for a pointer to pointer to member type. However, if the pointer to member representation has not been locked in yet, we would not be able to come up with a pointer to member IR type. In these cases, make the pointer to member type an incomplete type. This will make the pointer to pointer to member type a pointer to an incomplete type. If the class eventually obtains an inheritance model, we will make the pointer to member type represent the actual inheritance model. Differential Revision: http://reviews.llvm.org/D5373 llvm-svn: 218084
* Make all virtual member pointers use variadic musttail callsReid Kleckner2014-08-291-5/+5
| | | | | | | | | This avoids encoding information about the function prototype into the thunk at the cost of some function prototype bitcast gymnastics. Fixes PR20653. llvm-svn: 216782
* MS ABI: Don't force bases to have an inheritance modelDavid Majnemer2014-08-081-0/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, assigning an inheritance model to a derived class would trigger further assiginments to the various bases of the class. This was done to fix a bug where we couldn't handle an implicit base-to-derived conversion for pointers-to-members when the conversion was ambiguous at an earlier point. However, this is not how the MS scheme works. Instead, assign inheritance models to *just* the class which owns to declaration we ended up referencing. N.B. This result is surprising in many ways. It means that it is possible for a base to have a "larger" inheritance model than it's derived classes. It also means that bases in the conversion path do not get assigned a model. struct A { void f(); void f(int); }; struct B : A {}; struct C : B {}; void f() { void (C::*x)() = &A::f; } We can only begin to assign an inheritance model *after* we've seen the address-of but *before* we've done the implicit conversion the more derived pointer-to-member type. After that point, both 'A' and 'C' will have an inheritance model but 'B' will not. Surprising, right? llvm-svn: 215174
* MS ABI: Fix inheritance model calculation in CRTPDavid Majnemer2014-06-131-4/+15
| | | | | | | | | | | | | | | | | CRTP-like patterns involve a class which inherits from another class using itself as a template parameter. However, the base class itself may try to create a pointer-to-member which involves the derived class. This is problematic because we may not have finished parsing the most derived classes' base specifiers yet. It turns out that MSVC simply uses the unspecified inheritance model instead of doing anything fancy. This fixes PR19987. llvm-svn: 210886
* s/pr2007/20007/ in a testReid Kleckner2014-06-121-6/+6
| | | | llvm-svn: 210834
* MS ABI: Fix forming pointers to members of a base classReid Kleckner2014-06-121-2/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | Previously we would calculate the inheritance model of a class when requiring a pointer to member type of that class to be complete. The inheritance model is used to figure out how many fields are used by the member pointer. However, once we require a pointer to member of a derived class type to be complete, we can form pointers to members of bases without calculating the inheritance model for those bases. This was causing crashes on this simple test case: struct A { void f(); void f(int); }; struct B : public A {}; void g() { void (B::*a)() = &B::f; } Now we calculate the inheritance models of all base classes when completing a member pointer type. Fixes PR2007. llvm-svn: 210813
* Win64: Pass member pointers larger than 8 bytes by referenceReid Kleckner2014-05-021-0/+24
| | | | | | | | | | | | | The Win64 ABI docs on MSDN say that arguments bigger than 8 bytes are passed by reference. Prior to this change, we were only applying this logic to RecordType arguments. This affects both the Itanium and Microsoft C++ ABIs. Reviewers: majnemer Differential Revision: http://reviews.llvm.org/D3587 llvm-svn: 207817
* MS ABI: Fix logic bug in member pointer null test codeReid Kleckner2014-05-021-2/+2
| | | | | | | | | This code is trying to test if the pointer is *not* null. Therefore we should use 'or' instead of 'and' to combine the results of 'icmp ne'. This logic is consistent with the general member pointer comparison code in EmitMemberPointerComparison. llvm-svn: 207815
* MS ABI: Include the vfptr offset in memptrs to virtual methodsReid Kleckner2014-02-211-0/+23
| | | | | | | | | | | | | | | Virtual methods expect 'this' to point to the vfptr containing the virtual method, and this extends to virtual member pointer thunks. The relevant vfptr is always at offset zero on entry to the thunk, and no this adjustment is needed. Previously we would not include the vfptr adjustment in the member pointer, and we'd look at the vfptr offset when loading from the vftable in the thunk. Fixes PR18917. llvm-svn: 201835
* Sema: Do not assert when dereferencing member pointer using virtual ↵David Majnemer2014-02-201-0/+15
| | | | | | | | | | | | | | inheritance with an incomplete class type The MS ABI requires that we determine the vbptr offset if have a virtual inheritance model. Instead, raise an error pointing to the diagnostic when this happens. This fixes PR18583. Differential Revision: http://llvm-reviews.chandlerc.com/D2842 llvm-svn: 201824
* [ms-cxxabi] Raise aggregate memptr alignment to 8 for x86_32Reid Kleckner2014-01-311-29/+29
| | | | | | | | | | | | | | | | With this change, we give different results for __alignof than MSVC, but our record layout is compatible. Some data member pointers also now have a size that is not a multiple of their alignment. Fixes PR18618. Reviewers: majnemer Differential Revision: http://llvm-reviews.chandlerc.com/D2669 llvm-svn: 200585
* Remove the -cxx-abi command-line flag.Hans Wennborg2014-01-141-1/+1
| | | | | | | | | | | | | | | 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 llvm-svn: 199250
* [ms-abi] Report VBPtrOffset correctlyWarren Hunt2014-01-141-2/+2
| | | | | | | | | | Although VBPtrs were being placed correctly by the ms-abi layout engine, their offsets were being improperly reported to the ASTRecordLayout builder due to a bug. This patch fixes that and fixes the test cases to use the correct values. y llvm-svn: 199168
* [ms-abi] Refactor Microsoft Record LayoutWarren Hunt2014-01-091-2/+2
| | | | | | | | | This patch refactors microsoft record layout to be more "natural". The most dominant change is that vbptrs and vfptrs are injected after the fact. This simplifies the implementation and the math for the offest for the first base/field after the vbptr. llvm-svn: 198818
* [ms-cxxabi] bitcast to i8* to deref a data member pointerReid Kleckner2013-12-051-0/+20
| | | | | | | | This was causing us to miscompile llvm::SymbolTableListTraits::getListOwner(), which uses data member pointers. llvm-svn: 196545
* [ms-cxxabi] Fix assert in unspecified inheritance memptr emissionReid Kleckner2013-10-151-0/+11
| | | | | | | | | If a class is using the unspecified inheritance model for member pointers and later we find the class is defined to use single inheritance, zero out the vbptr offset field of the member pointer when it is formed. llvm-svn: 192664
* [ms-cxxabi] Properly mangle member pointersDavid Majnemer2013-08-051-18/+18
| | | | | | | | | | 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. llvm-svn: 187753
* [ms-cxxabi] Fix vbptr offsets in memptrs when the vbptr is in an nvbaseReid Kleckner2013-06-051-3/+3
| | | | | | | | Also addresses a review comment from John from on r180985 by removing the "== -1" check, since it's now reusing the correct code which has the comment. llvm-svn: 183318
* [ms-cxxabi] Implement member pointer conversionsReid Kleckner2013-05-091-6/+171
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This only supports converting along non-virtual inheritance paths by changing the field offset or the non-virtual base adjustment. This implements three kinds of conversions: - codegen for Value conversions - Constant emission for APValue - Constant folding for CastExprs In almost all constant initialization settings EmitMemberPointer(APValue) is called, except when the expression contains a reinterpret cast. reinterpret casts end up being a big corner case because the null value changes between different kinds of member pointers. Reviewers: rsmith CC: cfe-commits Differential Revision: http://llvm-reviews.chandlerc.com/D741 llvm-svn: 181543
* [ms-cxxabi] Emit non-virtual member function pointersReid Kleckner2013-05-031-4/+55
| | | | | | | | | | | | | | Without any conversion, this is pretty straightforward. Most of the fields can be zeros. The order is: - field offset or pointer - nonvirtual adjustment (for MI functions) - vbptr offset (for unspecified) - virtual adjustment offset (for virtual inheritance) Differential Revision: http://llvm-reviews.chandlerc.com/D699 llvm-svn: 180985
* [ms-cxxabi] Implement member pointer comparisonsReid Kleckner2013-04-301-0/+88
| | | | | | | | | | | | | | | | | | Summary: Like Itanium, comparisons are basically bitwise comparisons of the two values, with an exception for null member function pointers. If two function pointers are null, only the function pointer field matters for comparison purposes. The rest of the bits can be arbitrary. We take advantage of this in isZeroInitializable(), and it may matter once we start emitting conversions. Reviewers: rjmccall CC: cfe-commits Differential Revision: http://llvm-reviews.chandlerc.com/D695 llvm-svn: 180800
* Cleanup: test source file does not need to be executableArnaud A. de Grandmaison2013-04-221-0/+0
| | | | llvm-svn: 180002
* Widen the checks in the ms abi memptr test to work under NDEBUGReid Kleckner2013-04-111-5/+5
| | | | llvm-svn: 179311
* [ms-cxxabi] Implement member pointer emission and dereferencingReid Kleckner2013-04-111-7/+180
| | | | | | | | | | | | | | | | | | | | | Summary: Handles all inheritance models for both data and function member pointers. Also implements isZeroInitializable() and refactors some of the null member pointer code. MSVC supports converting member pointers through virtual bases, which clang does not (yet?) support. Implementing that extension is covered by http://llvm.org/15713 Reviewers: rjmccall CC: cfe-commits Differential Revision: http://llvm-reviews.chandlerc.com/D613 llvm-svn: 179305
* [ms-cxxabi] Implement member data pointers for non-dynamic classesReid Kleckner2013-03-221-0/+51
Summary: For non-dynamic classes (no virtual bases), member data pointers are simple offsets from the base of the record. Dynamic classes use an aggregate for member data pointers and are therefore currently unsupported. Unlike Itanium, the ms ABI uses 0 to represent null for polymorphic classes. Non-polymorphic classes use -1 like Itanium, since 0 is a valid field offset. Reviewers: rjmccall CC: timurrrr, cfe-commits Differential Revision: http://llvm-reviews.chandlerc.com/D558 llvm-svn: 177753
OpenPOWER on IntegriCloud