Commit Graph

58 Commits

Author SHA1 Message Date
Fariborz Jahanian 57251782d0 Code gen for aggregate-valued properties and a test case.
llvm-svn: 60122
2008-11-26 22:36:09 +00:00
Daniel Dunbar 44b58a2c14 Fix 80-col violations.
llvm-svn: 60051
2008-11-25 21:53:21 +00:00
Fariborz Jahanian 9ac535162b Implemented ir-gen for 'implicit' properties using the new AST nodes.
llvm-svn: 59886
2008-11-22 22:30:21 +00:00
Fariborz Jahanian 8a1810f06b New AST node to access "implicit" setter/getter using property dor syntax.
Issuing diagnostics when assigning to read-only properties.
This is work in progress.

llvm-svn: 59874
2008-11-22 18:39:36 +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
Chris Lattner 68e486804f Rename IdentifierInfo::isName to ::isStr. Use a nifty trick
from Sebastian to enforce that a literal string is passed in,
and use this to avoid having to call strlen on it.

llvm-svn: 59706
2008-11-20 04:42:34 +00:00
Chris Lattner e503373e67 fix save-o
llvm-svn: 59611
2008-11-19 08:26:36 +00:00
Chris Lattner d9c7bcf4bc simplify
llvm-svn: 59610
2008-11-19 08:24:49 +00:00
Chris Lattner 8488c8297c This reworks some of the Diagnostic interfaces a bit to change how diagnostics
are formed.  In particular, a diagnostic with all its strings and ranges is now
packaged up and sent to DiagnosticClients as a DiagnosticInfo instead of as a 
ton of random stuff.  This has the benefit of simplifying the interface, making
it more extensible, and allowing us to do more checking for things like access
past the end of the various arrays passed in.

In addition to introducing DiagnosticInfo, this also substantially changes how 
Diagnostic::Report works.  Instead of being passed in all of the info required
to issue a diagnostic, Report now takes only the required info (a location and 
ID) and returns a fresh DiagnosticInfo *by value*.  The caller is then free to
stuff strings and ranges into the DiagnosticInfo with the << operator.  When
the dtor runs on the DiagnosticInfo object (which should happen at the end of
the statement), the diagnostic is actually emitted with all of the accumulated
information.  This is a somewhat tricky dance, but it means that the 
accumulated DiagnosticInfo is allowed to keep pointers to other expression 
temporaries without those pointers getting invalidated.

This is just the minimal change to get this stuff working, but this will allow
us to eliminate the zillions of variant "Diag" methods scattered throughout
(e.g.) sema.  For example, instead of calling:

  Diag(BuiltinLoc, diag::err_overload_no_match, typeNames,
       SourceRange(BuiltinLoc, RParenLoc));

We will soon be able to just do:

  Diag(BuiltinLoc, diag::err_overload_no_match)
      << typeNames << SourceRange(BuiltinLoc, RParenLoc));

This scales better to support arbitrary types being passed in (not just 
strings) in a type-safe way.  Go operator overloading?!

llvm-svn: 59502
2008-11-18 07:04:44 +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 75283ff38a Centralize basic block creation in CodeGenFunction::createBasicBlock.
- No functionality change.

llvm-svn: 59017
2008-11-11 02:29:29 +00:00
Douglas Gregor 8ea1f53420 Add a new expression class, ObjCSuperExpr, to handle the Objective-C 'super'. Remove ObjCThis from PredefinedExpr
llvm-svn: 58698
2008-11-04 14:56:14 +00:00
Daniel Dunbar 354d278518 Debug info bug fix, function start wasn't getting generated correctly
for Obj-C methods.

llvm-svn: 57769
2008-10-18 18:22:23 +00:00
Chris Lattner 5d3e26a4f6 silence release-assert warnings.
llvm-svn: 57392
2008-10-12 00:31:50 +00:00
Ted Kremenek 3fef35736e Use DeclStmt::getSolitaryDecl() instead of DeclStmt::getDecl() when processing the Decl of an Objective-C foreach statement.
llvm-svn: 57209
2008-10-06 20:59:48 +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 a08dff1be1 Implement Obj-C getter synthesis for copy and retain.
Also, "simple" getter synthesis no longer uses temporary AST objects.

llvm-svn: 56544
2008-09-24 04:04:31 +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
Daniel Dunbar bc915f4025 Factor CodeGenFunction::StartFunction out of GenerateCode and
StartObjCMethod.

llvm-svn: 56030
2008-09-09 23:14:03 +00:00
Daniel Dunbar 54bb1933b1 Use a unified return block.
- For the time being this means our emitted code is somewhat worse,
   especially for aggregates. This will be fixed.

llvm-svn: 56013
2008-09-09 21:00:17 +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
Daniel Dunbar 449a339ffd Set function attributes (sext, zext, etc.) on Objective-C methods.
llvm-svn: 55812
2008-09-04 23:41:35 +00:00
Daniel Dunbar 56b936ba32 Fix infinite loop in for ... in code generation.
- Patch via Thomas Clement, thanks!

llvm-svn: 55804
2008-09-04 21:54:37 +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
Anders Carlsson 756585963b Initial support for CodeGen of for ... in statements.
llvm-svn: 55580
2008-08-31 02:33:12 +00:00
Anders Carlsson 2e744e8aa6 Stub out CodeGenFunction::EmitObjCForCollectionStmt.
Add CodeGenFunction::EmitMemSetToZero and make AggExprEmitter::EmitAggregateClear use it.

llvm-svn: 55573
2008-08-30 19:51:14 +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 9e22c0d317 Add special "property reference" CodeGen::LValue type for emitting
Objective-C property references.
 - This handles property references "more correctly" but setters still
   don't work.

llvm-svn: 55534
2008-08-29 08:11:39 +00:00
Daniel Dunbar 55310df79c Initial support for Obj-C dot-syntax for getters.
llvm-svn: 55410
2008-08-27 06:57:25 +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 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 66912a1a6d Move all Obj-C runtime interaction into CodeGenFunction.
- Drop duplicate (and broken) code for sending messages.
 - Add EmitObjCProtocolExpr to CodeGenFunction.

llvm-svn: 55024
2008-08-20 00:28:19 +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 c4baa06d15 Add GetAddrOfConstantCString method
- Returns addr of constant for argument + '\0'.
 - I couldn't think of a better name.
 - Move appropriate users of GetAddrOfConstantString to this.

Rename getStringForStringLiteral to GetStringForStringLiteral.

Add GetAddrOfConstantStringFromLiteral
 - This combines GetAddrOfConstantString and
   GetStringForStringLiteral. This method can be, but is not yet, more
   efficient.

Change GetAddrOfConstantString to not add terminating '\0'
 - <rdar://problem/6140956>

llvm-svn: 54768
2008-08-13 23:20:05 +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 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 8d480594cf Change CodeGenModule to only create ObjC runtime for ObjC files
- Changed CodeGenModule::getObjCRuntime to return reference.
 - Added CodeGenModule::hasObjCRuntime predicate.

llvm-svn: 54645
2008-08-11 18:12:00 +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 6e8aa537f8 More #include cleaning
- Drop {Decl.h,DeclObjC.h,IdentifierTable.h} from Expr.h
 - Moved Sema::getCurMethodDecl() out of line (dependent on
   ObjCMethodDecl via dyn_cast).

llvm-svn: 54629
2008-08-11 05:35:13 +00:00
Chris Lattner 6307f19726 rename PreDefinedExpr -> PredefinedExpr
llvm-svn: 54605
2008-08-10 01:53:14 +00:00
Chris Lattner 6cfec78e48 avoid a lot of unneeded selector processing work by passing around
selectors instead of Value*'s.

llvm-svn: 52760
2008-06-26 04:42:20 +00:00
Chris Lattner 9a05d04a0d use cheaper/simpler getselector call for @selector exprs.
llvm-svn: 52759
2008-06-26 04:38:58 +00:00