summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/VTableBuilder.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Remove trailing spaceFangrui Song2018-07-301-283/+283
| | | | | | sed -Ei 's/[[:space:]]+$//' include/**/*.{def,h,td} lib/**/*.{cpp,h} llvm-svn: 338291
* Fix a mangling failure on clang-cl C++17Reid Kleckner2018-05-171-0/+5
| | | | | | | | | | | | | | MethodVFTableLocations in MigrosoftVTableContext contains canonicalized decl. But, it's sometimes asked to lookup for non-canonicalized decl, and that causes assertion failure, and compilation failure. Fixes PR37481. Patch by Taiju Tsuiki! Differential Revision: https://reviews.llvm.org/D46929 llvm-svn: 332639
* Remove \brief commands from doxygen comments.Adrian Prantl2018-05-091-1/+1
| | | | | | | | | | | | | | | | | | | This is similar to the LLVM change https://reviews.llvm.org/D46290. We've been running doxygen with the autobrief option for a couple of years now. This makes the \brief markers into our comments redundant. Since they are a visual distraction and we don't want to encourage more \brief markers in new code either, this patch removes them all. Patch produced by for i in $(git grep -l '\@brief'); do perl -pi -e 's/\@brief //g' $i & done for i in $(git grep -l '\\brief'); do perl -pi -e 's/\\brief //g' $i & done Differential Revision: https://reviews.llvm.org/D46320 llvm-svn: 331834
* Fix typos in clangAlexander Kornienko2018-04-061-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Found via codespell -q 3 -I ../clang-whitelist.txt Where whitelist consists of: archtype cas classs checkk compres definit frome iff inteval ith lod methode nd optin ot pres statics te thru Patch by luzpaz! (This is a subset of D44188 that applies cleanly with a few files that have dubious fixes reverted.) Differential revision: https://reviews.llvm.org/D44188 llvm-svn: 329399
* Fix some DenseMap use-after-rehash bugs and hoist MethodVFTableLocationReid Kleckner2018-04-021-12/+9
| | | | | | | | | | | | | | This re-lands r328845 with fixes for crbug.com/827810. The initial motiviation was to hoist MethodVFTableLocation to global scope so it could be forward declared. In this patch, I noticed that MicrosoftVTableContext uses some risky patterns. It has methods that return references to data stored in DenseMaps. I've made some of them return by value for trivial structs and I've moved some things into separate allocations. llvm-svn: 329007
* Revert r328845, it caused crbug.com/827810.Nico Weber2018-03-311-4/+7
| | | | llvm-svn: 328922
* Hoist MethodVFTableLocation out of MicrosoftVTableContext, NFCReid Kleckner2018-03-291-7/+4
| | | | | | | | | | | | | This allows forward declaring it so that we can add it to MicrosoftMangleContext::mangleVirtualMemPtrThunk without including VTableBuilder.h. That saves a hashtable lookup when emitting virtual member pointer functions. It also shortens a really long type name. This struct has "VFtable" in the name, so it seems pretty unlikely that someone will assume it is generally useful for non-MS C++ ABI stuff. llvm-svn: 328845
* [MS] Fix bug in method vfptr location codeReid Kleckner2018-03-281-5/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We were assuming that vbtable indices were assigned in layout order in our comparison, which is not the case. When a virtual method, such as the destructor, appears in multiple vftables, the vftable that appears first in object layout order is the one that points to the main implementation of that method. The later vftables use thunks. In this layout, we adjusted "this" in the main implementation by the amount that is appropriate for 'B' instead of 'A', even though the main implementation is found in D's vftable for A: struct A { virtual ~A() {} }; struct B { virtual ~B() {} }; struct C : virtual B {}; struct D : virtual A, C {}; D's layout looks like: 0 D subobject (empty) 0 C base suboject 8 A base subobject 16 B base subobject With this fix, we correctly adjust by -8 in D's deleting destructor instead of -16. Fixes PR36921. llvm-svn: 328723
* [clang] Change std::sort to llvm::sort in response to r327219Mandeep Singh Grang2018-03-271-7/+7
| | | | | | | | | | | r327219 added wrappers to std::sort which randomly shuffle the container before sorting. This will help in uncovering non-determinism caused due to undefined sorting order of objects having the same key. To make use of that infrastructure we need to invoke llvm::sort instead of std::sort. llvm-svn: 328636
* Refactor overridden methods iteration to avoid double lookups.Benjamin Kramer2017-12-171-8/+3
| | | | | | Convert most uses to range-for loops. No functionality change intended. llvm-svn: 320954
* [ms] Fix vbtable index for covariant overrides of vbase methodsReid Kleckner2017-08-291-4/+6
| | | | | | | | | | | | | | | Overriding a method from a virtual base with a covariant return type consumes a slot from the vftable in the virtual base. This can make it impossible to implement certain diamond inheritance hierarchies, but we have to follow along for compatibility in the simple cases. This patch only affects our vtable dumper and member pointer function mangling, since all other callers of getMethodVFTableLocation seem to recompute VBTableIndex instead of using the one in the method location. Patch by David Majnemer llvm-svn: 312017
* CodeGen: New vtable group representation: struct of vtable arrays.Peter Collingbourne2016-12-131-57/+39
| | | | | | | | | In a future change, this representation will allow us to use the new inrange annotation on getelementptr to allow the optimizer to split vtable groups. Differential Revision: https://reviews.llvm.org/D22296 llvm-svn: 289584
* [AST] Don't use make_pointee_iterator in VTableBuilder.Justin Lebar2016-10-101-3/+4
| | | | | | | Our implementation of make_pointee_iterator seems to be causing MSVC 2015 to crash, so I'm going to remove it. llvm-svn: 283790
* Use unique_ptr for VTableBuilder::VBaseInfo map.Justin Lebar2016-10-101-15/+14
| | | | | | | | | | Reviewers: timshen Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D25424 llvm-svn: 283772
* Use unique_ptr for VTableBuilder::VFTableLayouts map.Justin Lebar2016-10-101-2/+1
| | | | | | | | | | Reviewers: timshen Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D25423 llvm-svn: 283771
* Use unique_ptr for VPtrLocationsMap and VPtrInfoVector.Justin Lebar2016-10-101-29/+32
| | | | | | | | | | Reviewers: timshen Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D25422 llvm-svn: 283770
* [AST] Use unique_ptr for VTableLayout.Justin Lebar2016-10-101-12/+10
| | | | | | | | | | Reviewers: timshen Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D25421 llvm-svn: 283769
* [MS] Improve VPtrInfo field names and doc commentsReid Kleckner2016-07-201-13/+13
| | | | | | | | | 'ReusingBase' was a terrible name. It might actually refer to the most derived class, which is not a base. 'BaseWithVPtr' was also bad, since again, it could refer to the most derived class. It was actually the first base to introduce the vptr, so now it is 'IntroducingObject'. llvm-svn: 276120
* Re-land "[MS] Don't expect vftables to be provided for extern template ↵Reid Kleckner2016-06-291-7/+6
| | | | | | | | | | | | | | instantiations" Reverts r273305 and re-instates r273296. We needed to fix a bug in Sema::MarkVTableUsed to ensure that operator delete lookup occurs when the vtable is referenced. We already had a special case to look up operator delete when dllimport was used, but I think should really mark virtual destructors referenced any time the vtable is used. llvm-svn: 274147
* Revert "[MS] Don't expect vftables to be provided for extern template ↵Reid Kleckner2016-06-211-6/+7
| | | | | | | | instantiations" This reverts commit r273296, it broke the Windows self-host. llvm-svn: 273305
* [MS] Don't expect vftables to be provided for extern template instantiationsReid Kleckner2016-06-211-7/+6
| | | | | | | | | | | | | MSVC doesn't provide them. PR28223 I left behind the machinery in case we want to resurrect available_externally vftable emission to support devirtualization. Reviewers: majnemer Differential Revision: http://reviews.llvm.org/D21544 llvm-svn: 273296
* Revert "Revert r260388 "[MS ABI] Never reference dllimport'd vtables""David Majnemer2016-02-111-6/+8
| | | | | | | | | | | | | This reverts commit r260449. We would supress our emission of vftable definitions if we thought another translation unit would provide the definition because we saw an explicit instantiation declaration. This is not the case with dllimport, we want to synthesize a definition of the vftable regardless. This fixes PR26569. llvm-svn: 260548
* Revert r260388 "[MS ABI] Never reference dllimport'd vtables"Hans Wennborg2016-02-101-0/+1
| | | | | | | This caused the compiler to fail with "invalid linkage type for global declaration" (PR26569). llvm-svn: 260449
* [MS ABI] Never reference dllimport'd vtablesDavid Majnemer2016-02-101-1/+0
| | | | | | | | | | | | | Referencing a dllimported vtable is impossible in a constexpr constructor. It would be friendlier to C++ programmers if we synthesized a copy of the vftable which referenced imported virtual functions. This would let us initialize the object in a way which preserves both the intent to import functionality from another DLL while also making constexpr work. Differential Revision: http://reviews.llvm.org/D17061 llvm-svn: 260388
* [MS ABI] Let arbitrary entities participate in vftable orderingDavid Majnemer2015-11-191-6/+10
| | | | | | | | | | | In the Microsoft ABI, the vftable is laid out in the order in the declaration order of the entities defined within it. Obviously, only virtual methods end up in the vftable but they will be placed into the table at the same position as the first entity with the same name. llvm-svn: 253523
* Roll-back r250822.Angel Garcia Gomez2015-10-201-1/+1
| | | | | | | | | | Summary: It breaks the build for the ASTMatchers Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D13893 llvm-svn: 250827
* Apply modernize-use-default to clang.Angel Garcia Gomez2015-10-201-1/+1
| | | | | | | | | | | | Summary: Replace empty bodies of default constructors and destructors with '= default'. Reviewers: bkramer, klimek Subscribers: klimek, alexfh, cfe-commits Differential Revision: http://reviews.llvm.org/D13890 llvm-svn: 250822
* [VTableBuilder] Use range-based for loops. No functional change intendedBenjamin Kramer2015-07-251-146/+96
| | | | llvm-svn: 243222
* [VTableBuilder] Turn functors into lambdasBenjamin Kramer2015-07-251-34/+24
| | | | | | No functional change intended. llvm-svn: 243221
* [AST] Turn the callbacks of lookupInBases and forallBases into a function_refBenjamin Kramer2015-07-251-8/+6
| | | | | | | | | This lets us pass functors (and lambdas) without void * tricks. On the downside we can't pass CXXRecordDecl's Find* members (which are now type safe) to lookupInBases directly, but a lambda trampoline is a small price to pay. No functionality change intended. llvm-svn: 243217
* Revert r240270 ("Fixed/added namespace ending comments using clang-tidy").Alexander Kornienko2015-06-221-1/+1
| | | | llvm-svn: 240353
* Fixed/added namespace ending comments using clang-tidy. NFCAlexander Kornienko2015-06-221-1/+1
| | | | | | | | | | | | The patch is generated using this command: $ tools/extra/clang-tidy/tool/run-clang-tidy.py -fix \ -checks=-*,llvm-namespace-comment -header-filter='llvm/.*|clang/.*' \ work/llvm/tools/clang To reduce churn, not touching namespaces spanning less than 10 lines. llvm-svn: 240270
* Wrap a few comments to 80 columns.Nico Weber2015-05-161-4/+7
| | | | llvm-svn: 237529
* [MS ABI] Cleanup selectBasePathDavid Majnemer2015-05-051-15/+15
| | | | | | | | | Handle some common cases quickly when deeper introspection into the path has no effect on the final result. No functional change intended. llvm-svn: 236475
* [MS ABI] Fix a crash in vptr path calculationDavid Majnemer2015-05-041-111/+151
| | | | | | | | | | | | | I discovered a case where the old algorithm would crash. Instead of trying to patch the algorithm, rewrite it. The new algorithm operates in three phases: 1. Find all paths to the subobject with the vptr. 2. Remove paths which are subsets of other paths. 3. Select the best path where 'best' is defined as introducing the most covariant overriders. If two paths introduce different overriders, raise a diagnostic. llvm-svn: 236444
* Remove some code left around for debugging purposesDavid Majnemer2015-05-011-12/+0
| | | | llvm-svn: 236355
* [MS ABI] Detect and diagnose vftables which cannot be createdDavid Majnemer2015-05-011-10/+42
| | | | | | | | | | | | | | | | The MSVC ABI has a bug introduced by appending to the end of vftables which come from virtual bases: covariant thunks introduces via non-overlapping regions of the inheritance lattice both append to the same slot in the vftable. It is possible to generate correct vftables in cases where one node in the lattice completely dominates the other on the way to the base with the vfptr; in all other cases, we must raise a diagnostic in order to prevent the illusion that we succeeded in laying out the vftable. This fixes PR16759. llvm-svn: 236354
* [MS ABI] NV bases may indirectly contain covariant thunks from V BasesDavid Majnemer2015-05-011-39/+24
| | | | | | | | | | | | A class might contain multiple ways of getting to a vbase, some of which are virtual and other non-virtual. It may be the case that a non-virtual base contains an override of a method in a vbase. This means that we must carefully pick between a set of nvbases to determine which is the best. As a consequence, the findPathForVPtr algorithm is considerably simpler. llvm-svn: 236353
* Remove some leftover debugging code.David Majnemer2015-04-301-1/+0
| | | | llvm-svn: 236243
* [MS ABI] Correctly make paths through covariant virtual basesDavid Majnemer2015-04-301-24/+94
| | | | | | | | | | | | There can be multiple virtual bases which are on the path to a vfptr when one vbase virtually inherits from another. We should prefer the most derived virtual base which covariantly overrides a method in the vfptr class; if we do not lengthen the path this way, we will end up with too few vftable entries. This fixes PR21073. llvm-svn: 236239
* [MS ABI] Use 'continue' instead of 'return false' where intendedReid Kleckner2015-04-271-4/+13
| | | | | | | | | | | | This was a bug in r218285 that prevented us from seeing subsequent virtual bases in the class hierarchy, leading to crashes later. Also add some comments to this function, now that we better understand what it's trying to do. Fixes PR21062 and PR21064. llvm-svn: 235899
* Move private classes into anonymous namespacesBenjamin Kramer2015-03-231-2/+2
| | | | | | Also merge anonymous namespaces in Targets.cpp a bit. NFC. llvm-svn: 232945
* MS ABI: Don't try to emit VF/VB-Tables for extern class templatesDavid Majnemer2015-03-181-1/+3
| | | | | | | | | There will be an explicit template instantiation in another translation unit which will provide the definition of the VF/VB-Tables. This fixes PR22932. llvm-svn: 232680
* Reland (2x) r230314, "Fix codegen for virtual methods that are (re-) ↵Reid Kleckner2015-02-251-0/+4
| | | | | | | | exported from multiple modules." This reverts commits r230477 and r230478. llvm-svn: 230526
* Whitespace.NAKAMURA Takumi2015-02-251-1/+1
| | | | llvm-svn: 230478
* Revert r230448, "Reland r230314 "Fix codegen for virtual methods that are ↵NAKAMURA Takumi2015-02-251-5/+1
| | | | | | (re-) exported from multiple modules."", since I have reverted r230446. llvm-svn: 230477
* Reland r230314 "Fix codegen for virtual methods that are (re-) exported from ↵Reid Kleckner2015-02-251-1/+5
| | | | | | | | | | multiple modules." This reverts the revert from commit r230406. The changes in r230445 and r230446 make the test pass on Windows now. llvm-svn: 230448
* Add missing MD canonicalization to MS vtable builderReid Kleckner2015-02-251-0/+1
| | | | llvm-svn: 230445
* Revert r230314, "Fix codegen for virtual methods that are (re-) exported ↵NAKAMURA Takumi2015-02-251-5/+1
| | | | | | | | | | from multiple modules." It crashes for targeting (i686|x86_64)-win32. clang: clang/lib/AST/VTableBuilder.cpp:142: {anonymous}::FinalOverriders::OverriderInfo {anonymous}::FinalOverriders::getOverrider(const clang::CXXMethodDecl*, clang::CharUnits) const: Assertion `OverridersMap.count(std::make_pair(MD, BaseOffset)) && "Did not find overrider!"' failed. llvm-svn: 230406
* Fix codegen for virtual methods that are (re-) exported from multiple modules.Manuel Klimek2015-02-241-1/+5
| | | | | | | Fixes multiple crashes where a non-canonical decl would be used as key in a lookup. llvm-svn: 230314
OpenPOWER on IntegriCloud