Commit Graph

93 Commits

Author SHA1 Message Date
Fariborz Jahanian 47f9a73f51 c++: support gcc's application of weak attribute on
class declaration which forces any such class and any 
class that inherits from such a class to have their 
typeinfo symbols be marked as weak.
// rdar://10246395
A    test/CodeGenCXX/weak-extern-typeinfo.cpp
M    lib/Sema/SemaDeclCXX.cpp
M    lib/Sema/SemaDeclAttr.cpp
M    lib/CodeGen/CGRTTI.cpp

llvm-svn: 142693
2011-10-21 22:27:12 +00:00
John McCall 59207978e6 More metaprogramming with builtin types.
llvm-svn: 142433
2011-10-18 22:28:37 +00:00
John McCall 8a6b59ad97 Add a new placeholder type to represent "unbridged"
casts in ARC.

No semantic analysis yet.

llvm-svn: 142208
2011-10-17 18:09:15 +00:00
Anton Korobeynikov f0c267e6e0 Provide half floating point support as a storage only type.
Lack of half FP was a regression compared to llvm-gcc.

llvm-svn: 142016
2011-10-14 23:23:15 +00:00
John McCall f937c023bf Rename TagDecl::isDefinition -> isCompleteDefinition
for better self-documenting code, since the semantics
are subtly different from getDefinition().

llvm-svn: 141355
2011-10-07 06:10:15 +00:00
Eli Friedman 0dfb889575 Support for C1x _Atomic specifier (see testcase). This is primarily being committed at the moment to help support C++0x <atomic>, but it should be a solid base for implementing the full specification of C1x _Atomic.
Thanks to Jeffrey Yasskin for the thorough review!

llvm-svn: 141330
2011-10-06 23:00:33 +00:00
Peter Collingbourne a834166e48 Create a VTableContext class and start moving CodeGenVTables methods to it
llvm-svn: 140502
2011-09-26 01:56:30 +00:00
David Blaikie 83d382b1ca Switch assert(0/false) llvm_unreachable.
llvm-svn: 140367
2011-09-23 05:06:16 +00:00
Peter Collingbourne e1d209911f CodeGen: rename CodeGenModule::Runtime to ObjCRuntime
llvm-svn: 136254
2011-07-27 20:29:46 +00:00
Chris Lattner 0e62c1cc0b remove unneeded llvm:: namespace qualifiers on some core types now that LLVM.h imports
them into the clang namespace.

llvm-svn: 135852
2011-07-23 10:55:15 +00:00
Jay Foad ed8db7d9df Convert ConstantExpr::getGetElementPtr and
ConstantExpr::getInBoundsGetElementPtr to use ArrayRef.

llvm-svn: 135673
2011-07-21 14:31:17 +00:00
Chris Lattner 2192fe50da de-constify llvm::Type, patch by David Blaikie!
llvm-svn: 135370
2011-07-18 04:24:23 +00:00
Chris Lattner e64d7ba153 Update to match mainline ConstantStruct::get API change. Also, use
ConvertType on InitListExprs as they are being converted.  This is
needed for a forthcoming patch, and improves the IR generated anyway
(see additional type names in testcases). 

This patch also converts a bunch of std::vector's in CGObjCMac to use
C arrays.  There are a ton more that should be converted as well.

llvm-svn: 133413
2011-06-20 04:01:35 +00:00
John McCall 0009fcc39e Make yet another placeholder type, this one marking that an expression is a bound
member function, i.e. something of the form 'x.f' where 'f' is a non-static
member function.  Diagnose this in the general case.  Some of the new diagnostics
are probably worse than the old ones, but we now get this right much more
universally, and there's certainly room for improvement in the diagnostics.

llvm-svn: 130239
2011-04-26 20:42:42 +00:00
Ken Dyck 499e93d7ee Eliminate a divide-by-8 in BuildVMIClassTypeInfo() by using CharUnits for
the base offset. No change in functionality intended.

llvm-svn: 129179
2011-04-09 01:09:56 +00:00
Ken Dyck bb4e977218 [Reapply r128776, modified so that it does not break debug info.]
Change the return type of CodeGenVTables::getVirtualBaseOffsetOffset() to
CharUnits. No change in functionality intended.

llvm-svn: 129072
2011-04-07 12:37:09 +00:00
John McCall 319963434c Basic, untested implementation for an "unknown any" type requested by LLDB.
The idea is that you can create a VarDecl with an unknown type, or a
FunctionDecl with an unknown return type, and it will still be valid to
access that object as long as you explicitly cast it at every use.  I'm
still going back and forth about how I want to test this effectively, but
I wanted to go ahead and provide a skeletal implementation for the LLDB
folks' benefit and because it also improves some diagnostic goodness for
placeholder expressions.

llvm-svn: 129065
2011-04-07 08:22:57 +00:00
Devang Patel 84852bbb42 Revert r128770, r128771, r128773 and r128776 for now. It breaks debug info.
llvm-svn: 128842
2011-04-04 20:36:06 +00:00
Ken Dyck 1473c9a7c4 Change the return type of CodeGenVTables::getVirtualBaseOffsetOffset() to
CharUnits. No change in functionality intended.

llvm-svn: 128776
2011-04-02 17:52:22 +00:00
David Chisnall e1d2584d44 Fix Objective-C++ exceptions (GNU runtime).
llvm-svn: 127980
2011-03-20 21:35:39 +00:00
Richard Smith 30482bc786 Implement the C++0x deduced 'auto' feature.
This fixes PR 8738, 9060 and 9132.

llvm-svn: 126069
2011-02-20 03:19:35 +00:00
Rafael Espindola 3968cd0f7b For consistency, use llvm::raw_ostream in the rest of the mangle api.
llvm-svn: 125360
2011-02-11 02:52:17 +00:00
Anders Carlsson a03f3a85cb When building with optimizations, emit vtables where the key is not in the
current translation unit as available_externally. 

This helps devirtualize the second example in PR3100, comment 18:

struct S { S() {}; virtual void xyzzy(); };
inline void foo(S *s) { s->xyzzy(); }
void bar() { S s; foo(&s); }

This involved four major changes:

1. In DefineUsedVTables, always mark virtual member functions as referenced for
   non-template classes and class template specializations.
2. In CodeGenVTables::ShouldEmitVTableInThisTU return true if optimizations are
   enabled, even if the key function is not implemented in this translation 
   unit. We don't ever do this for code compiled with -fapple-kext, because we
   don't ever want to devirtualize virtual member function calls in that case.
3. Give the correct linkage for vtables where the key function is not defined.
4. Update the linkage for RTTI structures when necessary.

llvm-svn: 124565
2011-01-30 20:45:54 +00:00
Anders Carlsson 5b48bf70a8 Remove dead code.
llvm-svn: 124554
2011-01-29 22:15:18 +00:00
Anders Carlsson 49f17537ee When emitting RTTI for a non-class type, compute the visibility of the RTTI data based on the explicit visibility of the type.
llvm-svn: 124553
2011-01-29 22:10:32 +00:00
Anders Carlsson 678632fa42 Add RTTIBuilder::GetAddrOfTypeName which uses the newly added CreateOrReplaceCXXRuntimeVariable.
Set the visibility for typeinfo names.

llvm-svn: 124548
2011-01-29 20:36:11 +00:00
Anders Carlsson 265aa7c070 Change CodeGenModule::setTypeVisibility to take a TypeVisibilityKind enum instead of an "IsForRTTI" flag.
llvm-svn: 124546
2011-01-29 20:24:48 +00:00
Anders Carlsson 883fc72c3c Make emitting a VTT a two-step process, much like emitting a VTable. You first get the address of the VTT, and then pass it to EmitVTTDefinition.
llvm-svn: 124539
2011-01-29 19:16:51 +00:00
Anders Carlsson fd4834061c Remove IsDefinition from CodeGenModule::setTypeVisibility; it is always true.
llvm-svn: 124529
2011-01-29 05:26:32 +00:00
Anders Carlsson 75286a7470 When building a type info struct for EH, we always want it to have linkonce_odr linkage.
llvm-svn: 124096
2011-01-24 02:12:11 +00:00
Anders Carlsson 68d3424b8c Change CodeGenModule::getVTableLinkage to be a non-static member function.
llvm-svn: 124095
2011-01-24 02:04:33 +00:00
Anders Carlsson 571e2ad042 Mark VTables and RTTI data linkonce_odr instead of weak_odr, with the exception of explicit template instantiations, which have to be weak_odr.
This fixes PR6996.

llvm-svn: 124089
2011-01-24 00:46:19 +00:00
Rafael Espindola 25f4620c67 Set unnamed_addr in every type info.
llvm-svn: 123293
2011-01-11 23:55:05 +00:00
Rafael Espindola b1e879c80f Set unnamed_addr for type infos that we are confortable marking as hidden. I
think it is safe to mark all type infos with unnamed_addr, but I am not sure.

llvm-svn: 123275
2011-01-11 21:44:37 +00:00
Chris Lattner ad3467ee89 The -fshort-wchar option causes wchar_t to become unsigned, in addition to being
16-bits in size.  Implement this by splitting WChar into two enums, like we have
for char.  This fixes a miscompmilation of XULRunner, PR8856.

llvm-svn: 122558
2010-12-25 23:25:43 +00:00
John McCall 09982c0a49 Give hidden visibility to RTTI for derived types. This is kindof a hacky
way to do this, but it fixes rdar://problem/8778973

llvm-svn: 122033
2010-12-17 02:58:03 +00:00
Anders Carlsson ba37e1eb49 std::nullptr_t is a fundamental type for RTTI purposes.
llvm-svn: 118238
2010-11-04 05:28:09 +00:00
Anders Carlsson fd88a6160d Rename getBaseClassOffset to getBaseClassOffsetInBits and introduce a getBaseClassOffset which returns the offset in CharUnits. Do the same thing for getVBaseClassOffset.
llvm-svn: 117881
2010-10-31 23:22:37 +00:00
John McCall c273f24196 Better solution: calculate the visibility of functions and variables
independently of whether they're definitions, then teach IR generation to
ignore non-explicit visibility when emitting declarations.  Use this to
make sure that RTTI, vtables, and VTTs get the right visibility.

More of rdar://problem/8613093

llvm-svn: 117781
2010-10-30 11:50:40 +00:00
John McCall 457a04e3ce Substantially revise how clang computes the visibility of a declaration to
more closely parallel the computation of linkage.  This gets us to a state
much closer to what gcc emits, modulo bugs, which will undoubtedly arise in
abundance.

llvm-svn: 117147
2010-10-22 21:05:15 +00:00
Benjamin Kramer fb5e584151 More class anonymization.
llvm-svn: 117106
2010-10-22 16:48:22 +00:00
Argyrios Kyrtzidis 0c34b138df Make sure the VTables for template instantiations are emitted even if the key function doesn't have a body.
llvm-svn: 116186
2010-10-11 03:25:57 +00:00
Argyrios Kyrtzidis f0e31c8b9c Don't let typeinfo name symbols be 'internal hidden', it can lead to linker conflicts
with similarly named classes in anonymous namespaces.

llvm-svn: 116185
2010-10-11 03:25:53 +00:00
John McCall 2917bd0fb4 Petty optimization.
llvm-svn: 113049
2010-09-04 01:26:37 +00:00
John McCall 5d865c3292 Teach IR generation to return 'this' from constructors and destructors
under the ARM ABI.

llvm-svn: 112588
2010-08-31 07:33:07 +00:00
Eli Friedman 04831926ec Detabify.
llvm-svn: 111768
2010-08-22 01:00:03 +00:00
Eli Friedman 1bb53d9cd6 Explicitly handle every case in the switch in RTTIBuilder::BuildTypeInfo.
llvm-svn: 111085
2010-08-15 00:24:31 +00:00
John McCall b3732bb3b7 Just disable the hidden-visibility optimization for now by hiding it behind
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
2010-08-12 23:36:15 +00:00
John McCall 398dc37d1f Implement RTTI generation for Objective C types. Fixes PR7864.
llvm-svn: 110900
2010-08-12 02:17:33 +00:00
Eli Friedman 961fc05418 Work in progress for PR7864. Someone more familiar with ObjC++ needs to fill
in the code after the "FIXME: Needs to be written".

llvm-svn: 110849
2010-08-11 20:41:51 +00:00