Paul Robinson
768efe7b26
Make two vtable tests tolerate C++11.
...
In C++11 we don't emit vtables as eagerly as we do for C++03, so
fiddle the tests to emit them when the test expects them.
Differential Revision: http://reviews.llvm.org/D27994
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@290205 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-20 22:22:24 +00:00
Reid Kleckner
152eee9f81
Make -fdump-vtable-layouts print to stdout, not stderr
...
This makes it consistent with -fdump-record-layouts, which was moved to
outs() in r186219. My reasoning for going with stdout is that when one
of these options is present, the layouts are really a program output,
and shouldn't be interleaved with diagnostics, which are on stderr.
Reviewers: timurrrr
Differential Revision: http://llvm-reviews.chandlerc.com/D2127
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@194279 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-08 21:28:00 +00:00
Timur Iskhodzhanov
e825cd0a91
... and actually run it
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@183309 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-05 13:50:24 +00:00
Timur Iskhodzhanov
d38dda9130
Add a test for the breakage from r183298
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@183308 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-05 13:49:11 +00:00
Timur Iskhodzhanov
4c44d2f5c5
Unrevert the tests from r183298 as they pass with both old and new code
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@183306 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-05 13:12:36 +00:00
Timur Iskhodzhanov
d38a21f588
Revert r183298 and r183300 as the former broke the virtual function lookup in libcxx __locale
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@183305 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-05 12:24:46 +00:00
Timur Iskhodzhanov
f19759ea38
Get rid of VTableContext::ComputeMethodVTableIndices() and VTableContext::getNumVirtualFunctionPointers(); also add some tests for the VTable indices output to make sure we don't regress
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@183298 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-05 06:36:37 +00:00
David Blaikie
d954ab47c6
Note deleted functions when dumping vtables.
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166056 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-16 20:25:33 +00:00
John McCall
260a3e4370
For the annals of subtle but terrible bugs: fix a longstanding bug
...
in vtable layout where virtual methods inherited from virtual bases
could be assigned the same vcall adjustment slot if they shared
a name and parameter signature but differed in their
cv-qualification. The code was already trying to handle this
case, but unfortunately used the ordinary type qualifiers
(which are always empty here) instead of the method qualifiers.
This seems like something that the API should discourage, but
I don't know how to carry that principle out in this instance.
Eliminate this function's need for an ASTContext while we're at it.
This bug affects the ABI, and fixing it brings us into accord with
the Itanium ABI (and GCC's implementation of it), but, obviously,
technically breaks full compatibility with previous releases of Clang.
Just letting you know.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153168 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-21 06:57:19 +00:00
Anders Carlsson
b8bced0b75
Change CollectPrimaryBases to collect the bases in the right order. Fixes one half of PR9660.
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@129252 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-10 18:00:32 +00:00
Chris Lattner
0c42bb653d
'const std::type_info*' instead of 'std::type_info const*'
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@113092 91177308-0d34-0410-b5e6-96231b3b80d8
2010-09-05 00:17:29 +00:00
Douglas Gregor
6fb745bdf1
Rework when and how vtables are emitted, by tracking where vtables are
...
"used" (e.g., we will refer to the vtable in the generated code) and
when they are defined (i.e., because we've seen the key function
definition). Previously, we were effectively tracking "potential
definitions" rather than uses, so we were a bit too eager about emitting
vtables for classes without key functions.
The new scheme:
- For every use of a vtable, Sema calls MarkVTableUsed() to indicate
the use. For example, this occurs when calling a virtual member
function of the class, defining a constructor of that class type,
dynamic_cast'ing from that type to a derived class, casting
to/through a virtual base class, etc.
- For every definition of a vtable, Sema calls MarkVTableUsed() to
indicate the definition. This happens at the end of the translation
unit for classes whose key function has been defined (so we can
delay computation of the key function; see PR6564), and will also
occur with explicit template instantiation definitions.
- For every vtable defined/used, we mark all of the virtual member
functions of that vtable as defined/used, unless we know that the key
function is in another translation unit. This instantiates virtual
member functions when needed.
- At the end of the translation unit, Sema tells CodeGen (via the
ASTConsumer) which vtables must be defined (CodeGen will define
them) and which may be used (for which CodeGen will define the
vtables lazily).
From a language perspective, both the old and the new schemes are
permissible: we're allowed to instantiate virtual member functions
whenever we want per the standard. However, all other C++ compilers
were more lazy than we were, and our eagerness was both a performance
issue (we instantiated too much) and a portability problem (we broke
Boost test cases, which now pass).
Notes:
(1) There's a ton of churn in the tests, because the order in which
vtables get emitted to IR has changed. I've tried to isolate some of
the larger tests from these issues.
(2) Some diagnostics related to
implicitly-instantiated/implicitly-defined virtual member functions
have moved to the point of first use/definition. It's better this
way.
(3) I could use a review of the places where we MarkVTableUsed, to
see if I missed any place where the language effectively requires a
vtable.
Fixes PR7114 and PR6564.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103718 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-13 16:44:06 +00:00
Anders Carlsson
fbf05613db
Fix a bug where we would sometimes incorrectly mark an vtable function as unused.
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101643 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-17 17:24:33 +00:00
Anders Carlsson
97913576db
Split adding the primary virtual base offsets out into a separate pass. This fixes a bug where we would lay out virtual bases in the wrong order.
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101373 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-15 16:12:58 +00:00
Nick Lewycky
69c05d5046
Typo.
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101015 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-12 05:32:01 +00:00
Anders Carlsson
73e6fa00ff
Fix another bug where we wouldn't generate secondary vtables for construction vtables in some cases.
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100998 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-11 22:20:36 +00:00
Anders Carlsson
af6ddf2071
Fix a bug where we were adding too many vcall offsets in some cases.
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100985 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-11 20:04:11 +00:00
Anders Carlsson
573021fc10
Fix another vbase layout bug.
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100952 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-10 21:35:33 +00:00
Anders Carlsson
f622b450d7
Fix a bug where we would add the same function twice in a vtable.
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100949 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-10 20:39:29 +00:00
Anders Carlsson
bdda6c1788
Simplify the virtual base layout code and fix a bug where we wouldn't store the offset for a virtual base.
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100940 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-10 18:42:27 +00:00
Anders Carlsson
adb507df13
Another vtable layout fix, making us match gcc better.
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99812 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-29 15:08:41 +00:00
Anders Carlsson
014a358058
Don't add address points for virtual primary bases that aren't primary bases in the complete class.
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99555 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-25 21:45:14 +00:00
Anders Carlsson
9135a84d8e
When dumping vtables, also dump the thunks.
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98799 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-18 02:44:19 +00:00
Anders Carlsson
127e46727e
Add a test.
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98246 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-11 06:44:31 +00:00
Anders Carlsson
2bc1d3a3b7
Fix calculation of whether a member function needs a thunk in construction vtables.
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98191 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-10 21:25:37 +00:00
Anders Carlsson
a96a2e961a
We were mistakenly marking morally virtual bases as being uninteresting. Fix this.
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98180 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-10 19:39:11 +00:00
Anders Carlsson
f2c98ce981
Ignore non-interesting bases when emitting construction vtables.
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98177 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-10 19:15:26 +00:00
Anders Carlsson
e35b768ac4
Add newline.
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98140 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-10 06:51:56 +00:00
Anders Carlsson
6039661c20
Don't accidentally mark some functions in construction vtables as unused. Also land the test for a previous checkin, now that it's correct.
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98139 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-10 06:51:42 +00:00
Anders Carlsson
ce57dd5f9f
Fix a bug with base offset merging that Devang noticed.
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97641 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-03 04:58:02 +00:00
Anders Carlsson
dad0f9918a
Handle unused functions in construction vtables correctly.
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97406 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-28 18:37:33 +00:00
Anders Carlsson
0378bf0840
When laying out vtables for virtual bases in construction vtables, we need to check if the vtable is a primary base in the layout class.
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97402 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-28 18:08:38 +00:00
Anders Carlsson
293126becf
Add another construction vtable test.
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97401 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-28 17:59:36 +00:00
Anders Carlsson
530c40c516
More improvements to construction vtables; we know handle vbase offsets correctly (I hope).
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97361 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-28 01:43:58 +00:00
Anders Carlsson
0041a64933
Add a simple construction vtable test.
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97344 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-27 21:09:00 +00:00
Anders Carlsson
6a8c5b2bc2
Use the real base offset when calculating vbase offsets.
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97338 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-27 19:21:58 +00:00
Anders Carlsson
8bc68f7a29
Don't add this adjustments for pure virtual member functions.
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97334 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-27 18:16:50 +00:00
Anders Carlsson
3504475548
Add another test.
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97329 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-27 16:55:58 +00:00
Anders Carlsson
2ef9d6bbd3
Finish up the changes to this adjustments.
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97328 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-27 16:52:49 +00:00
Anders Carlsson
c784ba21ba
Fix another vtable layout bug; we weren't looking hard enough for overriden functions when determining if an overrider will ever be used.
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97306 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-27 06:38:03 +00:00
Anders Carlsson
5560969d73
Handle vcall offset sharing between destructors.
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97304 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-27 04:12:52 +00:00
Anders Carlsson
08c26752ef
Fix a bug where we were generating an unnecessary vtable for a virtual base that's already a primary virtual base.
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97303 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-27 04:05:52 +00:00
Anders Carlsson
bf554f63bf
Fux a bug where we were trying to add overriders for non-virtual bases of virtual bases more than once.
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97173 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-25 22:18:35 +00:00
Anders Carlsson
af280c03a5
More fixes. Don't try to emit a virtual base vtable if the virtual base in question is a primary virtual base of some other base.
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96881 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-23 03:48:14 +00:00
Anders Carlsson
92f5432567
Always emit vcall offset for the primary base, not only if it's virtual. Remove a debug printf, and add the test case that now passes.
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96880 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-23 03:26:17 +00:00
Anders Carlsson
69dc04e948
Handle layout of vtables for virtual bases.
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96355 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-16 16:49:35 +00:00
Anders Carlsson
c7b631682f
Fix a bug where we would not emit secondary vtables for bases of a primary base.
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96351 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-16 16:02:57 +00:00
Anders Carlsson
852213e54a
Emit vbase offsets.
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96329 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-16 04:59:55 +00:00
Anders Carlsson
b828afa89a
Don't compute final overriders or build vtables for bases that don't need a vtable.
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96171 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-14 17:05:59 +00:00
Anders Carlsson
e67dc30725
Improve support for non-virtual 'this' pointer adjustments. With this, it should be possible to use the new vtable layout code for all class hierarchies that do not involve virtual bases.
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96137 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-14 00:16:19 +00:00