Commit Graph

1338 Commits

Author SHA1 Message Date
Daniel Dunbar ef2ffbc390 Fix pointer addressing and array subscripting of Objective-C interface
types.
 - I broke this in the switch to representing interfaces with opaque
   types.

 - <rdar://problem/6822660> clang crashes on subscript of interface in
   32-bit mode

llvm-svn: 70009
2009-04-25 05:08:32 +00:00
Fariborz Jahanian 969bc68195 Minor refactoring. No intended change in behavior.
llvm-svn: 69988
2009-04-24 21:07:43 +00:00
Fariborz Jahanian ce567657fd Minor refactoring. No change in functionality.
llvm-svn: 69979
2009-04-24 17:15:27 +00:00
Fariborz Jahanian a123b64218 Some code clean up of objc2's bitmap layout.
llvm-svn: 69970
2009-04-24 16:17:09 +00:00
Sanjiv Gupta 4742515771 Clang part of r69947. Reverting back 69574 as it is no longer needed.
llvm-svn: 69949
2009-04-24 02:40:57 +00:00
Douglas Gregor 89c8e000cf Fix handling of C99 "extern inline" semantics when dealing with
multiple declarations of the function. Should fix PR3989 and
<rdar://problem/6818429>.

llvm-svn: 69905
2009-04-23 18:22:55 +00:00
Devang Patel a6acb390e7 Handle corner case where clang-cc is invoked directly to compile preprocessed source file without -main-file-name. In this case, CDDebugInfo is not able identify correct main source file becase SM.isFromMainFile() returns true for locations from header files as well as locations from main source file.
This patch takes conservative approach by not emitting more then one compile unit with isMain bit set.

llvm-svn: 69902
2009-04-23 18:09:16 +00:00
Fariborz Jahanian 80672fce8f Removed bunch of FIXMEs no longer needed.
llvm-svn: 69896
2009-04-23 16:27:20 +00:00
Daniel Dunbar f0a8344bac Mark IMAGE_INFO as constant on x86_64-darwin.
- This shouldn't change anything, we never actually access it, but
   this is consistent with llvm-gcc (and 32-bit)

llvm-svn: 69880
2009-04-23 08:03:21 +00:00
Chris Lattner 324f80b12a fix a problem producing debug info with global blocks.
llvm-svn: 69875
2009-04-23 07:18:56 +00:00
Chris Lattner 7b0344f656 implement debug info for _Complex.
llvm-svn: 69873
2009-04-23 06:13:01 +00:00
Chris Lattner 28ec0cf86c the logic for computing __func__ and friends is really broken:
the type assigned by sema (and is visible with sizeof(__func__) for
example) has nothing to do with what codegen ends up producing.
We should eventually add a method on PredefinedExpr to handle this.
In the meantime, just set up some framework and add some fixme's.

llvm-svn: 69872
2009-04-23 05:30:27 +00:00
Daniel Dunbar 22b0ada8cf Use std::sort instead of qsort.
- Notably, there was a memory error here, SkipIvars does not have to
   be the same size as IvarsInfo.

 - Fariborz, please check.

llvm-svn: 69850
2009-04-23 01:29:05 +00:00
Douglas Gregor 29bd76fd04 Eliminate the three SmallVectors in ObjCImplDecl (for instance
methods, class methods, and property implementations) and instead
place all of these entities into the DeclContext.

This eliminates more linear walks when looking for class or instance
methods and should make PCH (de-)serialization of ObjCDecls trivial
(and lazy).

llvm-svn: 69849
2009-04-23 01:02:12 +00:00
Fariborz Jahanian 6df69867c3 ivar layout bitmap is alive!
llvm-svn: 69838
2009-04-22 23:00:43 +00:00
Daniel Dunbar e4f25b706b Reapply r69771, with updates & fixes:
Rework the shadow struct that is layed out for Objective-C classes.

 - Superclasses are now always laid out in their shadow structure at
   the first field.

 - Prior to this, the entire class heirarchy was flattened into a
   single structure which meant that alignment, padding, and bitfields
   were incorrect (the ASTRecordLayout was correct however, which
   meant our debug info didn't coincide with ivar offsets, for
   example).

 - This is still very suboptimal (for example, ivar are looked up
   recursively, but I believe the ivar layout itself is now at least
   close to correct.

 - <rdar://problem/6773388> error: objc[29823]: layout bitmap sliding
   backwards

llvm-svn: 69811
2009-04-22 17:43:55 +00:00
Daniel Dunbar 202f3dc5b3 Remove lookupFieldDeclFromIvar from ObjCIvarDecl interface.
- This is only used by CGObjCRuntime now.

llvm-svn: 69800
2009-04-22 12:00:04 +00:00
Daniel Dunbar 7d4e1c5e4a Don't convert interface types (to structs) as part of CodeGenTypes.
- This has pros and cons, but for now the pros seem to significantly
   outway the con.

The con is that we will always need to cast in the runtime
implementation to a struct type, if we wish to access an interface
directly.

The pros are:
 - Avoid the cost of generating types which are used. Most
   manipulation of Objective-C objects is done through messages, and
   only the implementation of a class will directly access
   memory. Previously, we would convert the type even if it only
   appear as a function parameter, for example.

 - We don't need to worry about incomplete types, and
   UpdateCompletedType for interfaces is gone.

 - It becomes easier to narrow the interface to the shadow struct for
   Objective-C interfaces (so it can be eliminated).

Currently the runtimes still use the CodeGenTypes machinery to
generate the LLVM structure they need via ConvertTagDecl, but this can
eventually be replaced.

llvm-svn: 69797
2009-04-22 10:28:39 +00:00
Daniel Dunbar 7b4dfc8b78 Add CGObjCRuntime::GetConcreteClassStruct to encapsulate access to the
underlying llvm::StructType for an interface.

llvm-svn: 69796
2009-04-22 09:39:34 +00:00
Daniel Dunbar 83a66f78d2 Simplify.
llvm-svn: 69793
2009-04-22 08:50:59 +00:00
Daniel Dunbar 725dc2c5bb Emit meta data using the Ivar, not a looked up FieldDecl.
llvm-svn: 69790
2009-04-22 08:22:17 +00:00
Daniel Dunbar 89623deca1 Use ComputeIvarBaseOffset instead of looking up by hand.
llvm-svn: 69789
2009-04-22 08:20:31 +00:00
Daniel Dunbar 9fd114d577 Merge ivar access amongst the three runtimes.
- For now, this means we are always doing the address computations by
   hand instead of constructing a proper GEP. Right now, however, this
   is less important than having fewer entry points to dealing with
   Objective-C interface layout.

llvm-svn: 69787
2009-04-22 07:32:20 +00:00
Chris Lattner 43e6f8c08b implement debug info support for id<proto> and interface<proto>
llvm-svn: 69784
2009-04-22 06:58:56 +00:00
Chris Lattner ad8f750f71 ObjCQualifiedClass is dead, remove it.
llvm-svn: 69783
2009-04-22 06:50:37 +00:00
Daniel Dunbar 722f424178 Make ObjCInterfaceDecl's const in some more places.
llvm-svn: 69775
2009-04-22 05:08:15 +00:00
Daniel Dunbar 658ba85820 Revert r69771, I missed some (obvious) details. :/
llvm-svn: 69773
2009-04-22 04:39:47 +00:00
Daniel Dunbar aefc2b9be3 Mark another TypeForDecl const and make getObjCInterfaceType's argument const.
llvm-svn: 69772
2009-04-22 04:34:53 +00:00
Daniel Dunbar 25b81ef847 Rework the shadow struct that is layed out for Objective-C classes.
- Superclasses are now always laid out their shadow structure at the
   first field.

 - Prior to this, the entire class heirarchy was flattened into a
   single structure which meant that alignment, padding, and bitfields
   weren't packed correctly (the ASTRecordLayout was correct however,
   which meant our debug info didn't coincide with ivar offsets, for
   example).

 - This is still very suboptimal, but I believe the ivar layout itself
   is now at least close to correct.

 - <rdar://problem/6773388> error: objc[29823]: layout bitmap sliding
   backwards

llvm-svn: 69771
2009-04-22 03:45:12 +00:00
Chris Lattner 2dfdb3ea94 move 64-bit abi functions to lazy model, everything is lazy now, yay.
llvm-svn: 69767
2009-04-22 02:53:24 +00:00
Chris Lattner ce8754edac remove the last of the non-lazy objc runtime functions for the 32-bit ABI,
7 left for 64-bit ABI.

llvm-svn: 69766
2009-04-22 02:44:54 +00:00
Chris Lattner 0a696a42fe number of non-lazy runtime functions from 9 -> 4.
llvm-svn: 69765
2009-04-22 02:38:11 +00:00
Chris Lattner 095ac38f1c make message send functions lazy, we're down from 14 non-lazy functions to 9.
llvm-svn: 69764
2009-04-22 02:32:31 +00:00
Chris Lattner c6406dbf7f move more EH stuff to being lazily created. An empty .m file now
produces just 14 dead "declares" in llvm ir instead of 19.

llvm-svn: 69763
2009-04-22 02:26:14 +00:00
Chris Lattner a7c00b4c4c make try/catch objc runtime functions be lazily generated.
rdar://6809612

llvm-svn: 69762
2009-04-22 02:15:23 +00:00
Chris Lattner f8dc07369a Fix some mishandling of the attr(gnu_inline) mode when used with
extern.  Previously we would warn about it and ignore the attribute.
This is incorrect, it should be handled as a c89 "extern inline" 
function.  Many thanks to Matthieu Castet for pointing this out and
beating me over the head until I got it.

PR3988: extern inline function are not externally visible
llvm-svn: 69756
2009-04-22 00:03:30 +00:00
Chris Lattner 2f343dd5c8 fix PR4026: Clang can't codegen __func__ without implicit cast
llvm-svn: 69747
2009-04-21 23:00:09 +00:00
Daniel Dunbar d1148a7f72 Make sure to mark the interface as completed when we see an
@implementation that closes a @class delcaration.
 - I don't know how to make a test case for this, but this strengthens
   the invariants that hold internally. The functionality change here
   is the edit to SemaDeclObjC.cpp.

llvm-svn: 69728
2009-04-21 21:41:56 +00:00
Douglas Gregor fa9ab53d95 Fix emission of static tentative definitions referenced from other static functions
llvm-svn: 69699
2009-04-21 19:28:58 +00:00
Fariborz Jahanian f5fec02d0c More objc2's ivar layout bitmap. No change in functionality.
llvm-svn: 69695
2009-04-21 18:33:06 +00:00
Chris Lattner b534f6a601 don't bother emitting a zero byte memset at all. We used to get them
in cases like this:

typedef struct {
  short instance;
  char name[0];
} ATTR_LIST_ENTRY2;

void test() {
  ATTR_LIST_ENTRY2 X = (ATTR_LIST_ENTRY2) { .instance = 7, };
}  

While it is safe to emit them, it is pretty silly.

llvm-svn: 69687
2009-04-21 17:59:23 +00:00
Douglas Gregor beecd58e21 Explictly track tentative definitions within Sema, then hand those
tentative definitions off to the ASTConsumer at the end of the
translation unit. 

Eliminate CodeGen's internal tracking of tentative definitions, and
instead hook into ASTConsumer::CompleteTentativeDefinition. Also,
tweak the definition-deferal logic for C++, where there are no
tentative definitions.

Fixes <rdar://problem/6808352>, and will make it much easier for
precompiled headers to cope with tentative definitions in the future.

llvm-svn: 69681
2009-04-21 17:11:58 +00:00
Sanjiv Gupta 4c5dfd3c45 Pass and return aggregate types directly to function calls.
llvm-svn: 69668
2009-04-21 06:01:16 +00:00
Chris Lattner a9aeea9f27 use of predefined identifiers like __func__ at global scope warn in sema,
but crashed codegen.  Fix this to report the name of the llvm function.
This fixes rdar://6808051

llvm-svn: 69658
2009-04-21 04:41:23 +00:00
Daniel Dunbar e000df6882 Remove unnused variable.
llvm-svn: 69650
2009-04-21 01:32:46 +00:00
Daniel Dunbar 9ebf9516af Kill ASTContext::[gs]etFieldForDecl, instead we just lookup things
when we need them -- which is exactly what some code was already
doing!
 - No intended functionality change.

llvm-svn: 69648
2009-04-21 01:19:28 +00:00
Daniel Dunbar be9dae80b3 Remove LateBoundIVars() runtime interface, it is unused.
llvm-svn: 69641
2009-04-21 00:49:20 +00:00
Daniel Dunbar e03f005d30 Assert on a few conditions that (I believe) should hold
w.r.t. ASTContext::[gs]etFieldDecl, and the Field argument to
EmitObjCValueForIvar).

llvm-svn: 69639
2009-04-21 00:41:40 +00:00
Fariborz Jahanian 80c9ce2c4a ObjC2's Ivar bitmap layout work. No change in functionality.
llvm-svn: 69629
2009-04-20 22:03:45 +00:00
Daniel Dunbar e3f5cfc0b8 Move countInheritedIvars to within striking distance of
GetClassSizeInfo

Reduce nesting in GetInterfaceDeclStructLayout.

Tweak some comments.

No functionality change.

llvm-svn: 69621
2009-04-20 20:18:54 +00:00