summaryrefslogtreecommitdiffstats
path: root/clang/test/CodeGenCXX/rtti-linkage.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Revert r332028; see PR37545 for details.Richard Smith2018-05-211-34/+22
| | | | llvm-svn: 332879
* [Itanium] Emit type info names with external linkage.Eric Fiselier2018-05-101-22/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The Itanium ABI requires that the type info for pointer-to-incomplete types to have internal linkage, so that it doesn't interfere with the type info once completed. Currently it also marks the type info name as internal as well. However, this causes a bug with the STL implementations, which use the type info name pointer to perform ordering and hashing of type infos. For example: ``` // header.h struct T; extern std::type_info const& Info; // tu_one.cpp #include "header.h" std::type_info const& Info = typeid(T*); // tu_two.cpp #include "header.h" struct T {}; int main() { auto &TI1 = Info; auto &TI2 = typeid(T*); assert(TI1 == TI2); // Fails assert(TI1.hash_code() == TI2.hash_code()); // Fails } ``` This patch fixes the STL bug by emitting the type info name as linkonce_odr when the type-info is for a pointer-to-incomplete type. Note that libc++ could fix this without a compiler change, but the quality of fix would be poor. The library would either have to: (A) Always perform strcmp/string hashes. (B) Determine if we have a pointer-to-incomplete type, and only do strcmp then. This would require an ABI break for libc++. Reviewers: rsmith, rjmccall, majnemer, vsapsai Reviewed By: rjmccall Subscribers: smeenai, cfe-commits Differential Revision: https://reviews.llvm.org/D46665 llvm-svn: 332028
* Revert "[Itanium] Emit type info names with external linkage."Eric Fiselier2018-05-101-34/+22
| | | | | | | This reverts commit r331957. It seems to be causing failures on ppc64le-linux. llvm-svn: 331963
* [Itanium] Emit type info names with external linkage.Eric Fiselier2018-05-101-22/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The Itanium ABI requires that the type info for pointer-to-incomplete types to have internal linkage, so that it doesn't interfere with the type info once completed. Currently it also marks the type info name as internal as well. However, this causes a bug with the STL implementations, which use the type info name pointer to perform ordering and hashing of type infos. For example: ``` // header.h struct T; extern std::type_info const& Info; // tu_one.cpp #include "header.h" std::type_info const& Info = typeid(T*); // tu_two.cpp #include "header.h" struct T {}; int main() { auto &TI1 = Info; auto &TI2 = typeid(T*); assert(TI1 == TI2); // Fails assert(TI1.hash_code() == TI2.hash_code()); // Fails } ``` This patch fixes the STL bug by emitting the type info name as linkonce_odr when the type-info is for a pointer-to-incomplete type. Note that libc++ could fix this without a compiler change, but the quality of fix would be poor. The library would either have to: (A) Always perform strcmp/string hashes. (B) Determine if we have a pointer-to-incomplete type, and only do strcmp then. This would require an ABI break for libc++. Reviewers: rsmith, rjmccall, majnemer, vsapsai Reviewed By: rjmccall Subscribers: smeenai, cfe-commits Differential Revision: https://reviews.llvm.org/D46665 llvm-svn: 331957
* Emit DeferredDeclsToEmit in a DFS order.Rafael Espindola2015-01-221-4/+4
| | | | | | | | | | | | | | Currently we emit DeferredDeclsToEmit in reverse order. This patch changes that. The advantages of the change are that * The output order is a bit closer to the source order. The change to test/CodeGenCXX/pod-member-memcpys.cpp is a good example. * If we decide to deffer more, it will not cause as large changes in the estcases as it would without this patch. llvm-svn: 226751
* CodeGen: Don't set hidden visibility on symbols with local linkageDuncan P. N. Exon Smith2014-05-071-22/+25
| | | | llvm-svn: 208258
* RTTI symbols for visible local types may need weak linkage.John McCall2014-03-101-0/+38
| | | | | | | | | | | Previously, we would always emit them with internal linkage, but with hidden visibility when the function was hidden, which is an illegal combination, which could lead LLVM to actually emit them as strong hidden symbols with hilarious results. rdar://16265084 llvm-svn: 203503
* type_info objects are not unnamed_addr: the ABI requires us toJohn McCall2014-02-081-23/+23
| | | | | | | | | | unique them and permits the implementation of dynamic_cast (and anything else which knows it's working with a complete class type) to compare their addresses directly. rdar://16005328 llvm-svn: 201020
* Remove the -fhidden-weak-vtables -cc1 option. It was dead,John McCall2014-02-081-6/+6
| | | | | | gross, and increasingly replaced through other mechanisms. llvm-svn: 201011
* When emitting RTTI for a non-class type, compute the visibility of the RTTI ↵Anders Carlsson2011-01-291-1/+1
| | | | | | data based on the explicit visibility of the type. llvm-svn: 124553
* Update tests.Anders Carlsson2011-01-291-1/+1
| | | | | | I'm still not sure if having the typenames be visible with -hidden-weak-vtables, but I think it makes sense. llvm-svn: 124549
* Mark VTables and RTTI data linkonce_odr instead of weak_odr, with the ↵Anders Carlsson2011-01-241-16/+16
| | | | | | | | exception of explicit template instantiations, which have to be weak_odr. This fixes PR6996. llvm-svn: 124089
* Set unnamed_addr in every type info.Rafael Espindola2011-01-111-18/+18
| | | | llvm-svn: 123293
* Set unnamed_addr for type infos that we are confortable marking as hidden. IRafael Espindola2011-01-111-5/+5
| | | | | | think it is safe to mark all type infos with unnamed_addr, but I am not sure. llvm-svn: 123275
* Give hidden visibility to RTTI for derived types. This is kindof a hackyJohn McCall2010-12-171-0/+10
| | | | | | way to do this, but it fixes rdar://problem/8778973 llvm-svn: 122033
* test/CodeGenCXX/rtti-linkage.cpp: Get rid of sort(1) to remove XFAIL: win32.NAKAMURA Takumi2010-11-081-41/+36
| | | | | | On the certain system, bogus SORT.EXE is picked up. Its sort-order is incompatible to POSIX. llvm-svn: 118391
* Don't let typeinfo name symbols be 'internal hidden', it can lead to linker ↵Argyrios Kyrtzidis2010-10-111-1/+2
| | | | | | | | conflicts with similarly named classes in anonymous namespaces. llvm-svn: 116185
* Just disable the hidden-visibility optimization for now by hiding it behindJohn McCall2010-08-121-1/+1
| | | | | | | | a -cc1 option. The Darwin linker complains about mixed visibility when linking gcc-built objects with clang-built objects, and the optimization isn't really that valuable. Platforms with less ornery linkers can feel free to enable this. llvm-svn: 110979
* It turns out that linkers (at least, the Darwin linker) don't necessarilyJohn McCall2010-08-051-1/+1
| | | | | | | | | | | do the right thing with mixed-visibility symbols, so disable the visibility optimization where that's possible, i.e. with template classes (since it's possible that an arbitrary template might be subject to an explicit instantiation elsewhere). 447.dealII actually does this. I've put the code under an option that's currently not hooked up to anything. llvm-svn: 110374
* Emit standard-library RTTI with external linkage, not weak_odr.John McCall2010-08-041-4/+18
| | | | | | | | | | Apply hidden visibility to most RTTI; libstdc++ does not rely on exact pointer equality for the type info (just the type info names). Apply the same optimization to RTTI that we do to vtables. Fixes PR5962. llvm-svn: 110192
* typeid() produces type information for the cv-unqualified version ofDouglas Gregor2010-06-021-0/+11
| | | | | | the type. Thanks to Anders for the bug report! llvm-svn: 105314
* XFAIL a test on Win32.Daniel Dunbar2010-05-141-0/+4
| | | | llvm-svn: 103762
* Rework when and how vtables are emitted, by tracking where vtables areDouglas Gregor2010-05-131-32/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | "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. llvm-svn: 103718
* Drastically simplify the computation of linkage for typeinfo by usingDouglas Gregor2010-03-311-0/+1
| | | | | | | | the existing (and already well-tested) linkage computation for types, with minor tweaks for dynamic classes and (pointers to) incomplete types. Fixes PR6597. llvm-svn: 99968
* If the key function of a record is inline, then the RTTI data should have ↵Anders Carlsson2009-12-311-0/+9
| | | | | | weak_odr linkage. llvm-svn: 92371
* More RTTI cleanup, test that RTTI classes have the correct vtables.Anders Carlsson2009-12-301-1/+1
| | | | llvm-svn: 92284
* Handle enum types as well.Anders Carlsson2009-12-291-0/+9
| | | | llvm-svn: 92276
* Fix function type RTTI linkage and add tests.Anders Carlsson2009-12-291-1/+16
| | | | llvm-svn: 92266
* Remove cv-qualifiers from the argument to typeidDouglas Gregor2009-12-231-4/+7
| | | | llvm-svn: 92041
* Add tests for structs inside anonymous namespaces.Anders Carlsson2009-12-211-2/+17
| | | | llvm-svn: 91806
* Incomplete structs should also have internal linkage.Anders Carlsson2009-12-211-0/+2
| | | | llvm-svn: 91805
* Correcly handle pointers to member pointer types where the class or the ↵Anders Carlsson2009-12-201-0/+19
| | | | | | pointee is incomplete. llvm-svn: 91804
* Rework the way pointer types are handled by the RTTI builder. We now get the ↵Anders Carlsson2009-12-201-2/+17
| | | | | | right linkage for indirect pointers to incomplete structs. llvm-svn: 91799
* Update tests to use %clang_cc1 instead of 'clang-cc' or 'clang -cc1'.Daniel Dunbar2009-12-151-1/+1
| | | | | | | | | - This is designed to make it obvious that %clang_cc1 is a "test variable" which is substituted. It is '%clang_cc1' instead of '%clang -cc1' because it can be useful to redefine what gets run as 'clang -cc1' (for example, to set a default target). llvm-svn: 91446
* Use GetAddrOfRTTI when getting the RTTI pointer for a base class.Anders Carlsson2009-12-111-0/+16
llvm-svn: 91127
OpenPOWER on IntegriCloud