Commit Graph

333 Commits

Author SHA1 Message Date
Daniel Dunbar 7633cbf005 ABI handling API changes.
- Lift CGFunctionInfo creation up to callers of EmitCall.

 - Move isVariadic bit out of CGFunctionInfo, take as argument to
   GetFunctionType instead.

No functionality change.

llvm-svn: 63550
2009-02-02 21:43:58 +00:00
Fariborz Jahanian 9f84b78ac1 Refactored code gen for ivar access in preparation for
objc2 nonfragile ivar access code gen.

llvm-svn: 63541
2009-02-02 20:02:29 +00:00
Fariborz Jahanian c22f236e81 Use target alignment API to set objc2's meta-data
alignment.

llvm-svn: 63470
2009-01-31 02:43:27 +00:00
Daniel Dunbar 3cd20632ff Kill off CGCallInfo, always use CGFunctionInfo for encapsulating
function/call info.

llvm-svn: 63466
2009-01-31 02:19:00 +00:00
Fariborz Jahanian 0408723269 class meta-data belong to __objc_data section (in objc2
nonfragile abi).

llvm-svn: 63461
2009-01-31 01:07:39 +00:00
Fariborz Jahanian 822082517f Recognize class's visibility attribute and set its linkage
to private extern (in objc2 nonfragile abi).

llvm-svn: 63460
2009-01-31 00:59:10 +00:00
Fariborz Jahanian 75e0351adb Missed another mis-alignment of an objc2 meta-data.
llvm-svn: 63453
2009-01-30 23:51:52 +00:00
Fariborz Jahanian e46e284efd Setting correct alignent for objc2 meta-data.
llvm-svn: 63445
2009-01-30 23:15:42 +00:00
Fariborz Jahanian fa57e8e7ab add imag_info section and data (for objc2 nonfragile abi).
llvm-svn: 63430
2009-01-30 22:07:48 +00:00
Fariborz Jahanian 279abd31a9 Generate list of implemented classes and categories in their
own sections (related to objc2 nonfragile abi).

llvm-svn: 63418
2009-01-30 20:55:31 +00:00
Fariborz Jahanian 097feda5e0 Code gen. for @protocol expression in the new nonfragile abi.
llvm-svn: 63408
2009-01-30 18:58:59 +00:00
Fariborz Jahanian d9c28b808b Bug fixing involving method-list in protocol meta-data
(objc2 nonfragile-abi).

llvm-svn: 63351
2009-01-30 00:46:37 +00:00
Fariborz Jahanian 34fe880648 Random bug fix related to protocl metadata in categories in
non-fragile abi.

llvm-svn: 63343
2009-01-29 23:23:06 +00:00
Fariborz Jahanian 61cd4b56c3 Set protocol linkage and visibility correctly and
build protocol translation table meta-data (objc2
non-fragile abi).

llvm-svn: 63329
2009-01-29 20:10:59 +00:00
Fariborz Jahanian 56b3b77c7d Protocol meta-data for objc2's non-fragile abi.
Lot more to do in this area.

llvm-svn: 63326
2009-01-29 19:24:30 +00:00
Fariborz Jahanian d27a820ae2 Add setter/getter methods to the list of methods
of class's meta-data (related to objc2 nonfragile abi).

llvm-svn: 63251
2009-01-28 22:46:49 +00:00
Fariborz Jahanian 066347ec7b property metadata for objc2's nonfragile abi
llvm-svn: 63246
2009-01-28 22:18:42 +00:00
Fariborz Jahanian b042a59230 Some refactoring of common code. No change in functionality.
llvm-svn: 63218
2009-01-28 19:12:34 +00:00
Fariborz Jahanian 3d3426f321 Set visibility of ivar offset symbols according to
accessibility of the ivar (related to objc2's
non-fragile abi).

llvm-svn: 63166
2009-01-28 01:36:42 +00:00
Fariborz Jahanian 40a4bcd49b Generation of ivar-offset symbols in objc2's non-fragile abi.
Changed section names for meta-data (to match current gcc).

llvm-svn: 63163
2009-01-28 01:05:23 +00:00
Fariborz Jahanian e19a1f15ae After talking to our runtime guru, I added a comment.
llvm-svn: 63141
2009-01-27 22:27:56 +00:00
Fariborz Jahanian 7415caa3d4 ivar meta-data generation for nonfragile-abi.
Still more work to do in this area.

llvm-svn: 63126
2009-01-27 19:38:51 +00:00
Fariborz Jahanian d0e8e85afc Added a FIXME.
llvm-svn: 63071
2009-01-26 23:49:05 +00:00
Fariborz Jahanian 2612e149ef Build method-description-list for category meta-data
as well (for nonfragile-abi).

llvm-svn: 63062
2009-01-26 22:58:07 +00:00
Fariborz Jahanian 99113fd577 Method decription meta-data and its setting in class_ro_t
meta-data.

llvm-svn: 63043
2009-01-26 21:38:32 +00:00
Fariborz Jahanian 0c8d060715 Meta-data for nonfragile-abi's categories
llvm-svn: 63020
2009-01-26 18:32:24 +00:00
Fariborz Jahanian a887e63434 Compute instaceStart/instanceSize fields of the class_ro_t meta-data
for objc2's non-fragile abi.

llvm-svn: 62945
2009-01-24 23:43:01 +00:00
Fariborz Jahanian 4723fb70a9 Patch to build class meta-data for each implementation
of class in objc2's nonfragile abi.

llvm-svn: 62935
2009-01-24 21:21:53 +00:00
Fariborz Jahanian 9e3ad5220d This patch builds the meta-class object for each
implemented class in objc2's nonfrigile abi.

llvm-svn: 62929
2009-01-24 20:21:50 +00:00
Fariborz Jahanian 71394045e4 Some very early work for new objc's
meta-data generation.

llvm-svn: 62894
2009-01-23 23:53:38 +00:00
Fariborz Jahanian 7fa50496f6 Checked in an oops!
llvm-svn: 62853
2009-01-23 17:48:29 +00:00
Fariborz Jahanian 5a63e4cd53 Another missing LLVM type for objc2's new abi defined.
llvm-svn: 62852
2009-01-23 17:41:22 +00:00
Fariborz Jahanian 0232c0569f Define LLVM types for nonfragile abi metadata.
llvm-svn: 62830
2009-01-23 01:46:23 +00:00
Fariborz Jahanian b15a3d5969 Use NonFragileABI as name of new Next abi. More comments
for the new meta-data.

llvm-svn: 62806
2009-01-22 23:02:58 +00:00
Fariborz Jahanian eee54df5b6 More refactoring of common API to the common class for
the two Next's objc runtimes. More comments.

llvm-svn: 62735
2009-01-22 00:37:21 +00:00
Fariborz Jahanian 0b1ccdce88 Moved whole bunch of common APIs to the common class.
No change in functionality.

llvm-svn: 62729
2009-01-21 23:34:32 +00:00
Fariborz Jahanian 279eda6275 Refactoring ObjC Next's runtime classes in preparation for
the new ObjC's abi.

llvm-svn: 62721
2009-01-21 22:04:16 +00:00
Fariborz Jahanian 4b4c826999 Commented objective-c's metadata types. Minor clean up.
No change in functionality.

llvm-svn: 62646
2009-01-21 00:39:53 +00:00
Douglas Gregor 6e6ad602e5 Remove ScopedDecl, collapsing all of its functionality into Decl, so
that every declaration lives inside a DeclContext.

Moved several things that don't have names but were ScopedDecls (and,
therefore, NamedDecls) to inherit from Decl rather than NamedDecl,
including ObjCImplementationDecl and LinkageSpecDecl. Now, we don't
store empty DeclarationNames for these things, nor do we try to insert
them into DeclContext's lookup structure.

The serialization tests are temporarily disabled. We'll re-enable them
once we've sorted out the remaining ownership/serialiazation issues
between DeclContexts and TranslationUnion, DeclGroups, etc.

llvm-svn: 62562
2009-01-20 01:17:11 +00:00
Fariborz Jahanian 705c6d9cdd Patch to re-implement ivar-list meta-data generation to fix
cases of unnamed ivar bitfields.

llvm-svn: 62429
2009-01-17 19:36:33 +00:00
Douglas Gregor b3730b50c7 Cleanup DeclContext::addDecl and DeclContext::insert interface, from Piotr Rak
llvm-svn: 62122
2009-01-12 23:27:07 +00:00
Daniel Dunbar 62db95e891 (LLVM up) Match TargetData API change in LLVM TOT.
llvm-svn: 62101
2009-01-12 21:08:18 +00:00
Steve Naroff ba3dc38840 Convert property implementation to DeclContext::addDecl().
This completes the ObjCContainerDecl AST cleanup (for now).

llvm-svn: 62037
2009-01-11 12:47:58 +00:00
Fariborz Jahanian 0196a1cd2b This patch fixes the code gen failures which was a fallout from
not merging protocol properties into the classes which
use those protocols. With this patch, all my exceutable
test pass again.

llvm-svn: 62030
2009-01-10 21:06:09 +00:00
Douglas Gregor ffca3a21f1 Provide a new kind of iterator, the specific_decl_iterator, that
filters the decls seen by decl_iterator with two criteria: the dynamic
type of the declaration and a run-time predicate described by a member
function. This simplifies EnumDecl, RecordDecl, and ObjCContainerDecl
considerably. It has no measurable performance impact.

llvm-svn: 61994
2009-01-09 17:18:27 +00:00
Steve Naroff b3a8798253 Move property API's up to ObjCContainerDecl (removing a lot of duplicate code).
Add isa/cast/dyncast support for ObjCContainerDecl.
Renamed classprop_iterator/begin/end to prop_iterator/begin/end (the class prefix was confusing).
More simplifications to Sema::ActOnAtEnd()...
Added/changed some FIXME's as a result of the above work.

llvm-svn: 61988
2009-01-09 15:36:25 +00:00
Fariborz Jahanian 475831bd6e Another nasty code gen. bug with trivial fix. Calling class
method on 'super' receiver in a category implementation.
Other simpler cases were working by accident.

llvm-svn: 61880
2009-01-07 20:11:22 +00:00
Fariborz Jahanian 1d35f12e6b More encoding support. This time for
@encode of classes and bitfields.

llvm-svn: 61268
2008-12-19 23:34:38 +00:00
Fariborz Jahanian b517e90662 Code gen. for ivar references; including bitfield
ivars.

llvm-svn: 61043
2008-12-15 20:35:07 +00:00
Douglas Gregor 91f84216f7 Unifies the name-lookup mechanisms used in various parts of the AST
and separates lexical name lookup from qualified name lookup. In
particular:
  * Make DeclContext the central data structure for storing and
    looking up declarations within existing declarations, e.g., members
    of structs/unions/classes, enumerators in C++0x enums, members of
    C++ namespaces, and (later) members of Objective-C
    interfaces/implementations. DeclContext uses a lazily-constructed
    data structure optimized for fast lookup (array for small contexts,
    hash table for larger contexts). 

  * Implement C++ qualified name lookup in terms of lookup into
    DeclContext.

  * Implement C++ unqualified name lookup in terms of
    qualified+unqualified name lookup (since unqualified lookup is not
    purely lexical in C++!)

  * Limit the use of the chains of declarations stored in
    IdentifierInfo to those names declared lexically.

  * Eliminate CXXFieldDecl, collapsing its behavior into
    FieldDecl. (FieldDecl is now a ScopedDecl).

  * Make RecordDecl into a DeclContext and eliminates its
    Members/NumMembers fields (since one can just iterate through the
    DeclContext to get the fields).

llvm-svn: 60878
2008-12-11 16:49:14 +00:00
Anders Carlsson a726c1763a Append an extra newline to the module inline asm if it's not empty.
llvm-svn: 60827
2008-12-10 02:21:04 +00:00
Chris Lattner f3d3faeca6 Rename NamedDecl::getName() to getNameAsString(). Replace a bunch of
uses of getName() with uses of getDeclName().  This upgrades a bunch of
diags to take DeclNames instead of std::strings.

This also tweaks a couple of diagnostics to be cleaner and changes
CheckInitializerTypes/PerformInitializationByConstructor to pass
around DeclarationNames instead of std::strings.

llvm-svn: 59947
2008-11-24 05:29:24 +00:00
Chris Lattner 86d7d91366 Rename NamedDecl::getIdentifierName() to ::getNameAsCString() and make it
assert if the name is not an identifier.  Update callers to do the right
thing and avoid this method in unsafe cases.  This also fixes an objc
warning that was missing a space, and migrates a couple more to taking
IdentifierInfo and QualTypes instead of std::strings.

llvm-svn: 59936
2008-11-24 03:54:41 +00:00
Chris Lattner e4b95698df Rename Selector::getName() to Selector::getAsString(), and add
a new NamedDecl::getAsString() method.

Change uses of Selector::getName() to just pass in a Selector 
where possible (e.g. to diagnostics) instead of going through
an std::string.

This also adds new formatters for objcinstance and objcclass
as described in the dox.

llvm-svn: 59933
2008-11-24 03:33:13 +00:00
Fariborz Jahanian e2caaaa13c Fixed bugzilla bug# 3095 related to code gen. for @synchronized.
llvm-svn: 59838
2008-11-21 19:21:53 +00:00
Fariborz Jahanian c2ad6dc3b4 Consolidated @try and @synchronize into a single
code gen. method.

llvm-svn: 59767
2008-11-21 00:49:24 +00:00
Fariborz Jahanian e881b536e8 Introducing objc_assign_ivar to clang.
llvm-svn: 59740
2008-11-20 19:23:36 +00:00
Fariborz Jahanian 50a1270d87 Few more changes due to Daniel's feedback.
llvm-svn: 59645
2008-11-19 17:34:06 +00:00
Fariborz Jahanian d7db964495 Generate strong write barriers for __strong objects.
Also, took care of Daniel's commments.

llvm-svn: 59575
2008-11-19 00:59:10 +00:00
Fariborz Jahanian 83f45b55f8 Patch for generation of weak write barriers for objc
__weak objects.

llvm-svn: 59560
2008-11-18 22:37:34 +00:00
Fariborz Jahanian f5125d19e7 Generate objc_read_weak for __weak objc loads.
llvm-svn: 59553
2008-11-18 21:45:40 +00:00
Fariborz Jahanian 406b117eea Some basic support toward objective-c's GC code gen.
llvm-svn: 59543
2008-11-18 20:18:11 +00:00
Douglas Gregor 77324f3854 Introduction the DeclarationName class, as a single, general method of
representing the names of declarations in the C family of
languages. DeclarationName is used in NamedDecl to store the name of
the declaration (naturally), and ObjCMethodDecl is now a NamedDecl.

llvm-svn: 59441
2008-11-17 14:58:09 +00:00
Chris Lattner e132e2432a Start implementing support for @synchonized with the darwin ObjC API.
Patch by Fariborz!

llvm-svn: 59377
2008-11-15 21:26:17 +00:00
Daniel Dunbar 5c7e3935f1 Rework IRgen invariant w.r.t. current insert point.
- EmitStmt is no longer required to finish with a current insertion
   point defined (i.e. it does not need to make dummy
   blocks). Instead, it can clear the insertion point in the builder
   which indicates that the current insertion point is unreachable.
 - CodeGenFunction provides HaveInsertPoint and EnsureInsertPoint
   which respectively test if there is an insert point and ensure an
   insertion point exists (by making a dummy block).
 - Clearly mark functions in CodeGenFunction which can be called with
   no insertion point defined. Currently this is a limited set, and
   EmitStmt simply EnsureInsertPoint()s before emitting subsequent IR.

Remove EmitDummyBlock, which is no longer needed. Clients who haven't
already cleared the insertion point (typically via EmitBranch) can do
so by hand.

Remove isDummyBlock, which has effectively been renamed to
HaveInsertPoint.

The main thrust of this change is that we no longer have create dummy
blocks just to destroy them a short time later in EmitBlock in the
common case that there is no unreachable code following something like
a goto. 

Additionally, this means that we are not using the hokey condition in
isDummyBlock that a block without a name is a dummy block. Guess how
well that works when we never emit block names!

llvm-svn: 59089
2008-11-11 23:11:34 +00:00
Daniel Dunbar c56e67644f Add CodeGenFunction::EmitBranch.
- Emits an unconditional branch, with extra logic to avoid generating
   spurious branches out of dummy blocks.

llvm-svn: 59037
2008-11-11 09:41:28 +00:00
Daniel Dunbar 29ac59f25c Add CodeGenFunction::EmitDummyBlock for marking places where we make
"dummy" blocks (blocks just used to make sure we have a place to dump
code to).

llvm-svn: 59022
2008-11-11 04:34:23 +00:00
Daniel Dunbar 75283ff38a Centralize basic block creation in CodeGenFunction::createBasicBlock.
- No functionality change.

llvm-svn: 59017
2008-11-11 02:29:29 +00:00
Daniel Dunbar cb4638599c Move IRBuilder type definition to common file.
- No functionality change.

llvm-svn: 58546
2008-11-01 01:53:16 +00:00
Daniel Dunbar c475d4224b NeXT: Emit protocol objects lazily.
- That is, the metadata for a protocol is only emitted if that
   protocol is actually used in the translation unit. This is
   important because Objective-C headers frequently contain a large
   number of protocol definitions, only a few of which will be used in
   any given file.

llvm-svn: 58400
2008-10-29 22:36:39 +00:00
Daniel Dunbar fc1066db81 Remove unneeded EncodingRecordTypes argument to getObjCEncodingForType.
llvm-svn: 57716
2008-10-17 20:21:44 +00:00
Daniel Dunbar ff3c6747ef More Obj-C type encoding improvements.
- Encode unions and bit-fields correctly.
 - Accept option to name record fields (used for NeXT runtime).

llvm-svn: 57685
2008-10-17 16:17:37 +00:00
Daniel Dunbar 3c683f5bf2 NeXT: Use objc_msgSend_fpret for calling functions which return
floating point. This is only correct for x86-32 at the moment.

llvm-svn: 57667
2008-10-17 03:24:53 +00:00
Ted Kremenek a7297be859 Use DeclStmt::getSolitaryDecl() instead of DeclStmt::getDecl() when processing the Decl of a @catch statement.
llvm-svn: 57208
2008-10-06 20:58:56 +00:00
Daniel Dunbar c3d16493ae (LLVM up) Rename IRBuilder::IsNonNull -> IsNotNull.
llvm-svn: 56954
2008-10-02 17:05:36 +00:00
Daniel Dunbar fbe68a84f8 NeXT: Update to use CreateRuntimeFunction for the routines it imports.
llvm-svn: 56902
2008-10-01 01:06:06 +00:00
Daniel Dunbar 2efd538f61 Add infrastructure for proper @finally support.
- Provides a basic primitive to jump to an arbitrary basic block,
   through the finally code.

 - Only used for return statements and rethrow currently. Still need
   to handle break, continue and goto.

 - Code still needs to be shuffled around to live elsewhere.

llvm-svn: 56827
2008-09-30 01:06:03 +00:00
Daniel Dunbar d3dcb4f8ed Add support for implicit rethrows in @catch blocks.
Comment exception-handling code generation strategy.

llvm-svn: 56763
2008-09-28 01:03:14 +00:00
Daniel Dunbar 7f08678f7d (Update LLVM) Clean up obj-c exception generation to be a bit more
readable and to generate more readable IR.

llvm-svn: 56758
2008-09-27 23:30:04 +00:00
Daniel Dunbar 86919f45cc Bug fix, codegen @catch(id<X> ...) acceptably.
- This should be rejected by sema (IMHO) but that needs some
   investigation.

llvm-svn: 56756
2008-09-27 22:21:14 +00:00
Daniel Dunbar 523208fb4a Simplify generate code for exceptions:
- There is no need to branch on the rethrow variable to determine if
   we need to call objc_exception_try_exit. We know whether an
   exception was thrown, so just branch to a different target if we
   want to skip the try_exit. 

   This is a slight semantic departure from gcc, but only for throwing
   nil, which is undefined (and for which gcc emits broken code).

 - Also fixes a bug in current code which was calling try_exit too
   many times when an exception was uncaught (but there were some
   handlers).

Fix bug introduced in prev. commit, the type of the @catch parameter
was uninitialized.

llvm-svn: 56754
2008-09-27 07:36:24 +00:00
Daniel Dunbar b22ff59750 Bug fix, make sure to initialize exception object (to rethrow) even
when there are no @catch blocks.

Also, eliminated unneeded alloca for the rethrow object.

Also, avoid generating code to rethrow exception if the exception will
trivially always be caught.

llvm-svn: 56751
2008-09-27 07:03:52 +00:00
Daniel Dunbar da04d7f4ec Easy fix for nasty bug, exception data buffer had wrong type == wrong
(smaller) size == garbage on stack == heisenbugs.

llvm-svn: 56750
2008-09-27 06:32:25 +00:00
Daniel Dunbar 5449ce5d75 Implement Obj-C synthesized setters for copy / retain.
llvm-svn: 56547
2008-09-24 06:32:09 +00:00
Daniel Dunbar a91c3e097f Add Obj-C runtime methods to get runtime specific functions for
implementing property access.

llvm-svn: 56542
2008-09-24 03:38:44 +00:00
Anders Carlsson 9396a89899 Make sure to store the exception in the catch parameter.
llvm-svn: 56102
2008-09-11 09:15:33 +00:00
Anders Carlsson b5130d8588 Make sure to emit the catch parameter as well as the catch body.
llvm-svn: 56101
2008-09-11 08:21:54 +00:00
Anders Carlsson 3a3c2444d6 Fix stupid mistake I made in the exception handling code
llvm-svn: 56100
2008-09-11 06:35:14 +00:00
Daniel Dunbar b8b4759462 Add CodeGenTypes::GetFunctionType overload for getting the effective
type of a call.

Change NeXT runtime to use this instead of trying to bitcasting
internally (which doesn't respect the ABI).

Fix subtle bug, use of ConvertTypeRecursive instead of ConvertType is
bad inside GetFunctionType.

llvm-svn: 56050
2008-09-10 07:00:50 +00:00
Daniel Dunbar 7a95ca3197 Move FunctionType conversion into CGCall.cpp:
- Added CodeGenTypes::GetFunctionType, taking a CGFunctionInfo.
 - Updated Obj-C runtimes to use this instead of rolling the
   llvm::FunctionType by hand.
 - Killed CodeGenTypes::{ConvertReturnType, DecodeArgumentTypes}.

Add ABIArgInfo class to encapsulate ABI decision of how to lower types
to LLVM.
 - Will move to target sometime soon.

llvm-svn: 56047
2008-09-10 04:01:49 +00:00
Daniel Dunbar c68897d2c3 Tweak CGCall functions again:
- Realized these functions will eventually need access to more data,
   moved to CodeGenModule. Eventually they should probably live
   together in some other helper class.

llvm-svn: 56039
2008-09-10 00:41:16 +00:00
Daniel Dunbar 81cf67fa0b Add CodeGenFunction::ReturnTypeUsesSret
- Hook so NeXT runtime doesn't depend on ABI.

llvm-svn: 56034
2008-09-09 23:48:28 +00:00
Anders Carlsson 4f1c7c3773 Check in half-assed implementation of @try/@catch.
llvm-svn: 55994
2008-09-09 17:59:25 +00:00
Anders Carlsson e005aa13f1 Simple @throw support.
llvm-svn: 55991
2008-09-09 16:16:55 +00:00
Anders Carlsson 9ff22483fd Add types and functions related to exceptions.
llvm-svn: 55984
2008-09-09 10:10:21 +00:00
Anders Carlsson 1963b0c38f Move handling of @try and @throw to the runtime class.
llvm-svn: 55983
2008-09-09 10:04:29 +00:00
Daniel Dunbar 41cf9dedc6 Change CodeGen to emit calls using (RValue,Type) list:
- Add CodeGenFunction::EmitAnyExprToTemp
   o Like EmitAnyExpr, but emits aggregates to a temporary location if
     none is available. Seems like this should be simpler (even aside
     from using first class aggregates).

 - Killed CodeGenFunction::EmitCallArg (just append the pair)

 - Conversion of RValues to actual call arguments is now isolated in
   CodeGenFunction::EmitCall.

llvm-svn: 55970
2008-09-09 01:06:48 +00:00
Ted Kremenek 2147570258 Change struct forward declarations and definitions to use unique RecordDecls, as opposed to creating a single RecordDecl and reusing it.
This change effects both RecordDecls and CXXRecordDecls, but does not effect EnumDecls (yet).

The motivation of this patch is as follows:
- Capture more source information, necessary for refactoring/rewriting clients.

- Pave the way to resolve ownership issues with RecordDecls with the forthcoming
  addition of DeclGroups.

Current caveats:
- Until DeclGroups are in place, we will leak RecordDecls not explicitly
  referenced by the AST.  For example:

    typedef struct { ... } x;  

  The RecordDecl for the struct will be leaked because the TypedefDecl doesn't
  refer to it.  This will be solved with DeclGroups.
  
- This patch also (temporarily) breaks CodeGen.  More below.

High-level changes:
- As before, TagType still refers to a TagDecl, but it doesn't own it.  When
  a struct/union/class is first referenced, a RecordType and RecordDecl are
  created for it, and the RecordType refers to that RecordDecl.  Later, if
  a new RecordDecl is created, the pointer to a RecordDecl in RecordType is
  updated to point to the RecordDecl that defines the struct/union/class.

- TagDecl and RecordDecl now how a method 'getDefinition()' to return the
  TagDecl*/RecordDecl* that refers to the TagDecl* that defines a particular
  enum/struct/class/union. This is useful from going from a RecordDecl* that
  defines a forward declaration to the RecordDecl* that provides the actual
  definition. Note that this also works for EnumDecls, except that in this case
  there is no distinction between forward declarations and definitions (yet).

- Clients should no longer assume that 'isDefinition()' returns true from a
  RecordDecl if the corresponding struct/union/class has been defined.
  isDefinition() only returns true if a particular RecordDecl is the defining
  Decl. Use 'getDefinition()' instead to determine if a struct has been defined.

- The main changes to Sema happen in ActOnTag. To make the changes more
  incremental, I split off the processing of enums and structs et al into two
  code paths. Enums use the original code path (which is in ActOnTag) and
  structs use the ActOnTagStruct. Eventually the two code paths will be merged,
  but the idea was to preserve the original logic both for comparison and not to
  change the logic for both enums and structs all at once.

- There is NO CHAINING of RecordDecls for the same RecordType. All RecordDecls
  that correspond to the same type simply have a pointer to that type. If we
  need to figure out what are all the RecordDecls for a given type we can build
  a backmap.

- The diff in CXXRecordDecl.[cpp,h] is actually very small; it just mimics the
  changes to RecordDecl. For some reason 'svn' marks the entire file as changed.

Why is CodeGen broken:
- Codegen assumes that there is an equivalence between RecordDecl* and
  RecordType*. This was true before because we only created one RecordDecl* for
  a given RecordType*, but it is no longer true. I believe this shouldn't be too
  hard to change, but the patch was big enough as it is.
  
I have tested this patch on both the clang test suite, and by running the static analyzer over Postgresql and a large Apple-internal project (mix of Objective-C and C).  

llvm-svn: 55839
2008-09-05 17:16:31 +00:00
Ted Kremenek 47923c7e59 Remove "NextDecl" from RecordDecl. This change touches many files that where RecordDecl or CXXRecordDecl was constructed, always with an argument of 'NULL' for the previous declaration.
The motivation behind this change is that chaining the RecordDecls is simply unnecessary.  Once we create multiple RecordDecls for the same struct/union/class, clients that care about all the declarations of the same struct can build a back map by seeing which Decls refer to the same RecordType.

llvm-svn: 55821
2008-09-05 01:34:33 +00:00
Daniel Dunbar 7050c55415 NeXT: Emit lazy reference to Protocol class for forward protocol
references (to match gcc).

llvm-svn: 55760
2008-09-04 04:33:15 +00:00
Daniel Dunbar c5d330400f Fix ObjCPropertRefExpr to be able to encode all the information for
uses which refer to methods not properties.
 - Not yet wired in Sema.

llvm-svn: 55681
2008-09-03 00:27:26 +00:00
Anders Carlsson 3f35a266da Handle mutation while enumerating correctly. Fix some bugs.
llvm-svn: 55583
2008-08-31 04:05:03 +00:00
Daniel Dunbar 4b8c6db927 Add Objective-C property setter support.
- Change Obj-C runtime message API, drop the ObjCMessageExpr arg in
   favor of just result type and selector. Necessary so it can be
   reused in situations where we don't want to cons up an
   ObjCMessageExpr.
 - Update aggregate binary assignment to know about special property
   ref lvalues.
 - Add CodeGenFunction::EmitCallArg overload which takes an already
   emitted rvalue.

Add CodeGenFunction::StoreComplexIntoAddr.

Disabled logic in Sema for parsing Objective-C dot-syntax that
accesses methods. This code does not search in the correct order and
the AST node has no way of properly representing its results.

Updated StmtDumper to print a bit more information about
ObjCPropertyRefExprs.

llvm-svn: 55561
2008-08-30 05:35:15 +00:00
Daniel Dunbar c722b8565c Refactor handling of calls:
- Added CodeGenFunction::EmitCall which just takes the callee, return
   type, and a list of (Value*,QualType) pairs.
 - Added CodeGenFunction::EmitCallArg which handles emitting code for
   a call argument and turning it into an appropriate
   (Value*,QualType) pair.
 - Changed Objective-C runtime interface so that the actual emission
   of arguments for message sends is (once again) done in the code to
   emit a message send.

No intended functionality change, this is prep work for better ABI
support and for Objective-C property setter support.

llvm-svn: 55560
2008-08-30 03:02:31 +00:00
Daniel Dunbar a799807dea Downgrade a number of FIXME asserts to ErrorUnsupported.
- Notably VLAs

llvm-svn: 55544
2008-08-29 17:28:43 +00:00
Daniel Dunbar 4932b36f54 NeXT: Emit mostly-correct property type encoding.
- Added ASTContext::getObjCEncodingForPropertyDecl.

llvm-svn: 55461
2008-08-28 04:38:10 +00:00
Daniel Dunbar eb1f9a2566 NeXT: Refactor protocol method metadata emission.
Also, fix category protocol list metadata.

llvm-svn: 55405
2008-08-27 02:31:56 +00:00
Daniel Dunbar 28e76caea1 NeXT: Emit correct properties for category.
- Was emitting duplicates of class properties instead of the category
   properties.

llvm-svn: 55395
2008-08-26 23:03:11 +00:00
Daniel Dunbar 3c76cb5cad NeXT: Emit metadata for synthetsized properties.
Also, fix method lookup to not use LLVM module symbol table.

llvm-svn: 55390
2008-08-26 21:51:14 +00:00
Daniel Dunbar 89654eef3a Objective-C @synthesize support.
- Only supports simple assignment and atomic semantics are ignored.
 - Not quite usable yet because the methods do not actually get added
   to the class metadata.
 - Added ObjCPropertyDecl::getSetterKind (one of Assign, Copy, Retain).
 - Rearrange CodeGenFunction so synthesis can reuse function prolog /
   epilog code.

llvm-svn: 55365
2008-08-26 08:29:31 +00:00
Daniel Dunbar ca8531a2d7 Fix Obj-C super sends inside class methods.
- NeXT loads the super class at runtime; this required changing the
   runtime interface to pass more information down.

llvm-svn: 55307
2008-08-25 08:19:24 +00:00
Daniel Dunbar c61d0e9ee9 NeXT: Emit symbols used to manage linking of Obj-C classes.
- This ensures that references to undefined classes cause link
   errors.
 - NOTE: This relies on platform specific asm directives currently,
   this should be factored out.

Also, don't emit a SYMBOLS metadata entry if there are no symbols.

llvm-svn: 55302
2008-08-25 06:02:07 +00:00
Daniel Dunbar d644ad61e9 NeXT: Clean up constant CFString handling.
- Use CodeGenModule::GetAddrOfConstantCFString

Some tweaks of CodeGenModule::GetAddrOfConstantCFString

llvm-svn: 55243
2008-08-23 18:37:06 +00:00
Daniel Dunbar 97ff50dd6e NeXT: Fix message sends which return structures.
- Simplify the sending code a bit.

llvm-svn: 55232
2008-08-23 09:25:55 +00:00
Daniel Dunbar f6397fed10 NeXT: Implement super message sends.
llvm-svn: 55225
2008-08-23 04:28:29 +00:00
Daniel Dunbar 97db84ce6d Trim CGObjCRuntime::GenerateMessageSend[Super]
- Returns an RValue.
 - Reduced to only taking the CodeGenFunction, Expr, and Receiver.
 - Becomes responsible for emitting the arguments.

Add CodeGenFunction::EmitCallExprExt
 - Takes optional extra arguments to insert at the head of the call.
 - This allows the Obj-C runtimes to call into this and isolates the
   argument and call instruction generation code to one place. Upshot
   is that we now pass structures (more) correctly.

Also, fix one aspect of generating methods which take structure
arguments (for NeXT). This probably needs to be merged with the
SetFunctionAttributes code in CodeGenModule.cpp

llvm-svn: 55223
2008-08-23 03:46:30 +00:00
Daniel Dunbar 80a840bc70 NeXT: Emit property metadata (classes, protocols, categories).
llvm-svn: 55209
2008-08-23 00:19:03 +00:00
Daniel Dunbar 938a77f4c9 NeXT: Emit category metadata.
llvm-svn: 55197
2008-08-22 20:34:54 +00:00
Daniel Dunbar dec75f895e NeXT: Emit [meta]class protocol references.
Updated ObjCProtocolDecl::protocol_iterator to match that of
ObjCInterfaceDecl.

llvm-svn: 55143
2008-08-21 21:57:41 +00:00
Daniel Dunbar 22d82ed0e2 Preliminary support for Obj-C classes in NeXT runtime.
- Functional for simple cases but there are some glaring omissions
   (protocols, properties, and other language extensions).
 - The code needs a fair bit of cleaning.

llvm-svn: 55108
2008-08-21 04:36:09 +00:00
Daniel Dunbar a94ecd2a0b Add NeXT runtime support for generating methods.
Change CodeGenFunction::EmitParmDecl to take either a ParmVarDecl or an
  ImplicitParamDecl.

Drop hasAggregateLLVMType from CodeGenModule.cpp (use version in
  CodeGenFunction).

Change the Objective-C method generation to use EmitParmDecl for
  implicit parameters.

llvm-svn: 54838
2008-08-16 03:19:19 +00:00
Daniel Dunbar 7c6d3a7c50 Change ObjCRuntime::LookupClass -> GetClass, and now takes the
ObjCInterfaceDecl.

Change ObjCRuntime::GenerateMessageSendSuper to take the
  ObjCInterfaceDecl for the super class, instead of just its name.

Change EmitObjCMessageExpr to make the right runtime calls for super
  sends in class methods (i.e. a super send with the class object as
  the receiver).

llvm-svn: 54833
2008-08-16 00:25:02 +00:00
Daniel Dunbar 9299250939 Change CGObjCRuntime methods to take appropriate clang Decls.
- This is in prep for implementation class support for the NeXT
   runtime, for which the existing methods don't provide enough
   information (and additionally make too many assumptions about how
   things should be emitted).

llvm-svn: 54824
2008-08-15 22:20:32 +00:00
Daniel Dunbar b036db8e66 Implement Obj-C protocol metadata generation for NeXT.
- Near complete, only properties are missing.

llvm-svn: 54715
2008-08-13 03:21:16 +00:00
Daniel Dunbar 89da6ad1db Change ObjCRuntime GenerateProtocol[Ref] methods to take
ObjCProtocolDecl directly.

Implement CodeGen support for forward protocol decls (no-ops are so
    nice to implement).

Also moved CGObjCRuntime.h out of CodeGenModule.h

llvm-svn: 54709
2008-08-13 00:59:25 +00:00
Daniel Dunbar 7bd00bda05 Emit OBJC_MODULE_INFO and OBJC_SYMBOLS metadata
- Matches llvm-gcc and seem to be expected by otool.

llvm-svn: 54669
2008-08-12 06:48:42 +00:00
Daniel Dunbar 5d71559c01 Drop Sender from GenerateMessageSend*
- Was unused and generated a unnecessary load of self

Update NeXT runtime to get proper object & selector types from
       ASTContext.

llvm-svn: 54667
2008-08-12 05:28:47 +00:00
Daniel Dunbar cb515c8b0a Add NeXT support for (simple) message sends.
llvm-svn: 54664
2008-08-12 03:39:23 +00:00
Daniel Dunbar 8b8683f9f6 Add ObjC constant string support for NeXT.
Changed CGObjCRuntime::GenerateConstantString interface to take
       std::string instead of char* and size.

Change ObjC functions which call on GenerateConstantString to bitcast
       result to appropriate type.

llvm-svn: 54659
2008-08-12 00:12:39 +00:00
Daniel Dunbar 3ad53483fb Add LangOptions::NeXTRuntime.
- Wired to -fnext-runtime and -fgnu-runtime options.
 - Defaults to GNU, no autoselection for NeXT.

Emit NeXT OBJC_IMAGE_INFO marker.

llvm-svn: 54651
2008-08-11 21:35:06 +00:00
Daniel Dunbar 56fdb6ae69 More #include cleaning
- Kill unnecessary #includes in .cpp files. This is an automatic
   sweep so some things removed are actually used, but happen to be
   included by a previous header. I tried to get rid of the obvious
   examples and this was the easiest way to trim the #includes in one
   fell swoop.
 - We now return to regularly scheduled development.

llvm-svn: 54632
2008-08-11 06:23:49 +00:00
Daniel Dunbar 221fa94e40 More #include cleaning
- Drop Expr.h,RecordLayout.h from ASTContext.h (for DeclBase.h and
   SourceLocation.h)
 - Move ASTContext constructor into implementation

llvm-svn: 54627
2008-08-11 04:54:23 +00:00
Daniel Dunbar 303e2c2f1f Add dummy Mac Objective-C runtime interface.
- Not currently accessible and completely non-functional.

llvm-svn: 54624
2008-08-11 02:45:11 +00:00