Commit Graph

58 Commits

Author SHA1 Message Date
Alp Toker 314cc81b8c Rename getResultType() on function and method declarations to getReturnType()
A return type is the declared or deduced part of the function type specified in
the declaration.

A result type is the (potentially adjusted) type of the value of an expression
that calls the function.

Rule of thumb:

  * Declarations have return types and parameters.
  * Expressions have result types and arguments.

llvm-svn: 200082
2014-01-25 16:55:45 +00:00
Alp Toker 9cacbabd33 Rename FunctionProtoType accessors from 'arguments' to 'parameters'
Fix a perennial source of confusion in the clang type system: Declarations and
function prototypes have parameters to which arguments are supplied, so calling
these 'arguments' was a stretch even in C mode, let alone C++ where default
arguments, templates and overloading make the distinction important to get
right.

Readability win across the board, especially in the casting, ADL and
overloading implementations which make a lot more sense at a glance now.

Will keep an eye on the builders and update dependent projects shortly.

No functional change.

llvm-svn: 199686
2014-01-20 20:26:09 +00:00
Benjamin Kramer 2210562249 Make helper function static.
llvm-svn: 199013
2014-01-11 18:42:35 +00:00
Reid Kleckner 5f08094106 [ms-cxxabi] Improve vbtable name mangling accuracy
Summary:
This makes us more compatible with MSVC 2012+ and fixes PR17748 where we
would give two tables the same name.

Rather than doing a fresh depth-first traversal of the inheritance graph
for every record's vbtables, now we memoize vbtable paths for each
record.  By doing memoization, we end up considering virtual bases of
subobjects that come later in the depth-first traversal.  Where
previously we would have ignored a virtual base that we'd already seen,
we now consider it for name mangling purposes without emitting a
duplicate vbtable for it.

Reviewers: majnemer

CC: cfe-commits

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

llvm-svn: 198462
2014-01-03 23:42:00 +00:00
Aaron Ballman 75ee4cc830 Removed one of the string versions of getQualifiedNameAsString, and switched over to using printQualifiedName where possible. No functional changes intended.
llvm-svn: 198433
2014-01-03 18:42:48 +00:00
Reid Kleckner b40a27dad8 [ms-cxxabi] Move VBTableBuilder from CodeGen over to AST/VTableBuilder.cpp
Summary:
No functionality change.

This code should live here long-term because we should be able to use it
to compute correct vftable names.

It turns out that the most natural way to implement the naming algorithm
is to use a caching layer similar to what we already have for virtual
table info in VTableContext.  Subsequent changes will take advantage of
this to fix PR17748, where we have a vbtable name collision.

Reviewers: majnemer

CC: cfe-commits

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

llvm-svn: 198380
2014-01-03 00:14:35 +00:00
Reid Kleckner 31a9f74c1d Reduce indentation of some VFTableBuilder code.
No functionality change.

llvm-svn: 198085
2013-12-27 20:29:16 +00:00
Reid Kleckner 558cab2f49 Fix incorrect copy-pasted method decl that MSVC allowed.
llvm-svn: 198081
2013-12-27 19:45:53 +00:00
Reid Kleckner 604c8b45e4 [ms-cxxabi] Emit fewer trivial return adjusting thunks
Most importantly, this makes our vtable layout match MSVC's.  Previously
we would emit a return adjusting thunk whenever the return types
differed, even if the adjustment would have been trivial.

MSVC does emit some trivial return adjusting thunks, but only if there
was already an overridden method that required a return adjustment.

llvm-svn: 198080
2013-12-27 19:43:59 +00:00
Reid Kleckner b60a3d5bc1 Eliminate the ItaniumVTableContext object from CodeGenVTables
Now CodeGenVTables has only one VTableContext object, which is either
Itanium or Microsoft.

Fixes a FIXME with no functionality change intended.

Ideally we could avoid the downcasts by pushing the things that
reference the Itanium vtable context into ItaniumCXXABI.cpp, but we're
not there yet.

llvm-svn: 197845
2013-12-20 23:58:52 +00:00
Reid Kleckner d2d1cc5156 Compare canonical return types when generating MS C++ ABI vtable thunks
This was part of the cause for PR17655.  We were generating thunks when
we shouldn't have.  I suspect that if we tweak the test case for PR17655
to actually require thunks, we can reproduce the same crash.

llvm-svn: 197836
2013-12-20 21:44:05 +00:00
Reid Kleckner 5bc6d0fbe4 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

llvm-svn: 194279
2013-11-08 21:28:00 +00:00
Timur Iskhodzhanov 2c9341f979 Thread the info about vbptr sharing through ASTRecordLayout
Reviewed at http://llvm-reviews.chandlerc.com/D2120

llvm-svn: 194256
2013-11-08 11:45:35 +00:00
Timur Iskhodzhanov 9e7f505515 Minor refinement of VTableBuilder.h: fix wrong indentation, rename a struct field with a more appropriate name
llvm-svn: 194202
2013-11-07 13:34:02 +00:00
Timur Iskhodzhanov 053142a90d Fix PR17738 - add support for vtordisp thunks when using -cxx-abi microsoft
llvm-svn: 194132
2013-11-06 06:24:31 +00:00
Timur Iskhodzhanov 5877663622 Fix vbtable indices when a class shares the vbptr with a non-virtual base
llvm-svn: 194082
2013-11-05 15:54:58 +00:00
Timur Iskhodzhanov 0201432a5e Make thunk this/return adjustment ABI-specific. Also, fix the return adjustment when using -cxx-abi microsoft
Reviewed at http://llvm-reviews.chandlerc.com/D2026

llvm-svn: 193679
2013-10-30 11:55:43 +00:00
Timur Iskhodzhanov 66f4381b39 Fix an assertion when handling a custom case of virtual inheritance; also reduce code duplication
llvm-svn: 193610
2013-10-29 14:13:45 +00:00
Timur Iskhodzhanov 8b14242fe5 Drop the unneeded VBase field from MethodInfo in the VFTableBuilder class
llvm-svn: 193164
2013-10-22 14:50:20 +00:00
Timur Iskhodzhanov 62082b7e0b [-cxx-abi microsoft] Fix this argument/parameter offsets for virtual destructors in the presence of virtual bases
Reviewed at http://llvm-reviews.chandlerc.com/D1939

llvm-svn: 192822
2013-10-16 18:24:06 +00:00
Benjamin Kramer 9f8e2d77c1 Reduce double set lookups by using the result of insert.
No functionality change.

llvm-svn: 192598
2013-10-14 15:16:10 +00:00
Timur Iskhodzhanov e1ebc5fb66 Code cleanup: rename VTableContext to ItaniumVTableContext, VTableBuilder to ItaniumVTableBuilder and clang-format code around
llvm-svn: 192288
2013-10-09 11:33:51 +00:00
Timur Iskhodzhanov ad9d3b8fd1 Reland 192220 "Abstract out parts of thunk emission code, add support for simple thunks when using -cxx-abi microsoft" with relaxed assertions
llvm-svn: 192285
2013-10-09 09:23:58 +00:00
Timur Iskhodzhanov c7113073dd Revert 192220 as it fails on an assertion
llvm-svn: 192225
2013-10-08 20:09:50 +00:00
Timur Iskhodzhanov 1ffb3916ce Abstract out parts of thunk emission code, add support for simple thunks when using -cxx-abi microsoft
Reviewed at http://llvm-reviews.chandlerc.com/D1787

llvm-svn: 192220
2013-10-08 19:15:38 +00:00
Timur Iskhodzhanov 20df98c0d0 Fix PR17382 - properly group virtual method overloads in the vftable
llvm-svn: 192067
2013-10-06 15:31:37 +00:00
Timur Iskhodzhanov 8b5987eba5 Abstract out the emission of vtables, add basic support for vtable emission when using -cxx-abi microsoft
Reviewed at http://llvm-reviews.chandlerc.com/D1532

llvm-svn: 191523
2013-09-27 14:48:01 +00:00
Timur Iskhodzhanov 88fd439a24 Abstract out virtual calls and virtual function prologue code generation; implement them for -cxx-abi microsoft
llvm-svn: 188870
2013-08-21 06:25:03 +00:00
Benjamin Kramer dca8abde77 Make helper function static.
llvm-svn: 187574
2013-08-01 11:08:06 +00:00
Timur Iskhodzhanov df7e7fb642 Add MicrosoftVFTableContext to AST
llvm-svn: 187409
2013-07-30 09:46:19 +00:00
Craig Topper 5603df45df Use SmallVectorImpl& for function arguments instead of SmallVector.
llvm-svn: 185715
2013-07-05 19:34:19 +00:00
Timur Iskhodzhanov 7f55a455d1 Simplify getting CXXRecordDecl from a base iterator
llvm-svn: 185438
2013-07-02 16:00:40 +00:00
Timur Iskhodzhanov 1151031eb7 Fix a trivial typo, add a FIXME to have more test coverage for VTableBuilder
llvm-svn: 185159
2013-06-28 15:42:28 +00:00
Eli Friedman b998bff32b Delete dead code.
llvm-svn: 185101
2013-06-27 20:48:08 +00:00
Timur Iskhodzhanov 05e3670498 Recommit r183298+r183300 'Get rid of VTableContext::ComputeMethodVTableIndices() and VTableContext::getNumVirtualFunctionPointers()'
In r183298, I've used llvm::SmallPtrSet<..., 8> instead of llvm::SmallVector<..., 8> for NewVirtualFunctionsTy by mistake.
This only manifested when a class had more than 8 virtual functions, which wasn't covered by unit-tests

llvm-svn: 183310
2013-06-05 14:05:50 +00:00
Timur Iskhodzhanov b640dd6f43 Revert r183298 and r183300 as the former broke the virtual function lookup in libcxx __locale
llvm-svn: 183305
2013-06-05 12:24:46 +00:00
David Blaikie d620e9da74 Fix fallout from r183298, unused function (CollectPrimaryBases) causing the -Werror build to fail
llvm-svn: 183300
2013-06-05 06:50:40 +00:00
Timur Iskhodzhanov be5a3d876c Fix the DUMP_OVERRIDERS macro in the VTableBuilder.cpp
llvm-svn: 183299
2013-06-05 06:40:07 +00:00
Timur Iskhodzhanov 12f1f84d12 Get rid of VTableContext::ComputeMethodVTableIndices() and VTableContext::getNumVirtualFunctionPointers(); also add some tests for the VTable indices output to make sure we don't regress
llvm-svn: 183298
2013-06-05 06:36:37 +00:00
Timur Iskhodzhanov bb5a17e8fa Fix one FIXME in VTableBuilder
llvm-svn: 181396
2013-05-08 08:09:21 +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
Benjamin Kramer 325d74566f CodeGen: Remove unnecessary const_casts. No functionality change.
llvm-svn: 174292
2013-02-03 18:55:34 +00:00
John McCall 359b885e12 First pass at abstracting out a class for the target C++ ABI.
llvm-svn: 173514
2013-01-25 22:30:49 +00:00
Timur Iskhodzhanov 52b8a05234 First step towards vftable generation with -cxx-abi microsoft PR13231
llvm-svn: 173035
2013-01-21 13:02:41 +00:00
Benjamin Kramer 444a1304ad Include pruning and general cleanup.
llvm-svn: 169095
2012-12-01 17:12:56 +00:00
David Blaikie 596d2cacc7 Note deleted functions when dumping vtables.
llvm-svn: 166056
2012-10-16 20:25:33 +00:00
Sylvestre Ledru 830885ca64 Fix a typo (the the => the)
llvm-svn: 160622
2012-07-23 08:59:39 +00:00
Benjamin Kramer 2ef3031496 Remove get(V)BaseClassOffsetInBits, the CharUnit functions should be used instead.
No functionality change.

llvm-svn: 159719
2012-07-04 18:45:14 +00:00
David Blaikie 40ed29730b Revert Decl's iterators back to pointer value_type rather than reference value_type
In addition, I've made the pointer and reference typedef 'void' rather than T*
just so they can't get misused. I would've omitted them entirely but
std::distance likes them to be there even if it doesn't use them.

This rolls back r155808 and r155869.

Review by Doug Gregor incorporating feedback from Chandler Carruth.

llvm-svn: 158104
2012-06-06 20:45:41 +00:00
David Blaikie 2d7c57ec1d Remove the ref/value inconsistency in filter_decl_iterator.
filter_decl_iterator had a weird mismatch where both op* and op-> returned T*
making it difficult to generalize this filtering behavior into a reusable
library of any kind.

This change errs on the side of value, making op-> return T* and op* return
T&.

(reviewed by Richard Smith)

llvm-svn: 155808
2012-04-30 02:36:29 +00:00