Commit Graph

318 Commits

Author SHA1 Message Date
Anders Carlsson e9766d559b If a cast expression needs either a conversion function or a constructor to be called, generate implicit child expressions that call them.
llvm-svn: 81383
2009-09-09 21:33:21 +00:00
Mike Stump 11289f4280 Remove tabs, and whitespace cleanups.
llvm-svn: 81346
2009-09-09 15:08:12 +00:00
Mike Stump 4a3999fe90 Reflow comments and some minor whitespace fixups.
llvm-svn: 81337
2009-09-09 13:00:44 +00:00
Anders Carlsson 2fb0824197 Vastly improve PredefinedExpr output, both in Sema and CodeGen. Patch by Sam Weinig!
llvm-svn: 81237
2009-09-08 18:24:21 +00:00
Douglas Gregor ad8a336b40 Implement AST, semantics, and CodeGen for C++ pseudo-destructor
expressions, e.g.,

  p->~T()

when p is a pointer to a scalar type. 

We don't currently diagnose errors when pseudo-destructor expressions
are used in any way other than by forming a call.

llvm-svn: 81009
2009-09-04 17:36:40 +00:00
Anders Carlsson c82555fb85 Handle member expressions that return references correctly.
llvm-svn: 80723
2009-09-01 21:18:52 +00:00
Fariborz Jahanian 1a50477385 Fixed a property getter ir-gen crash.
llvm-svn: 80681
2009-09-01 17:02:21 +00:00
Douglas Gregor f405d7e6f1 Eliminate CXXAdornedMemberExpr entirely. Instead, optionally allocate
space within the MemberExpr for the nested-name-specifier and its
source range. We'll do the same thing with explicitly-specified
template arguments, assuming I don't flip-flop again.

llvm-svn: 80642
2009-08-31 23:41:50 +00:00
Douglas Gregor 96ee789d33 Rename CXXQualifiedMemberExpr -> CXXAdornedMemberExpr, since we will
also be adding explicit template arguments as an additional
"adornment". No functionality change.

llvm-svn: 80628
2009-08-31 21:41:48 +00:00
Fariborz Jahanian 3df8767869 Patch for code gen. for c-style cast which ends in
using class's conversion functions [12.3.2-p2]

llvm-svn: 80433
2009-08-29 19:15:16 +00:00
Fariborz Jahanian 8b899e4247 ir-gen related patch for type conversion
with class type conversion methods. WIP.

llvm-svn: 80365
2009-08-28 15:11:24 +00:00
Eli Friedman ff083ef429 Clean up CodeGenFunction::EmitCastLValue to use the cast kind. Error
out for user-defined conversions instead of crashing.

llvm-svn: 80282
2009-08-27 21:19:33 +00:00
Douglas Gregor c190523d7a When a member reference expression includes a qualifier on the member
name, e.g.,
  
  x->Base::f()

retain the qualifier (and its source range information) in a new
subclass of MemberExpr called CXXQualifiedMemberExpr. Provide
construction, transformation, profiling, printing, etc., for this new
expression type.

When a virtual function is called via a qualified name, don't emit a
virtual call. Instead, call that function directly. Mike, could you
add a CodeGen test for this, too?

llvm-svn: 80167
2009-08-26 22:36:53 +00:00
Fariborz Jahanian 9a84665921 Using "ObjCImplicitSetterGetterRefExpr" instead of "ObjCImplctSetterGetterRefExpr".
A field rename and more comments.

llvm-svn: 79537
2009-08-20 17:02:02 +00:00
Fariborz Jahanian 88cc2340de Renamed ObjCKVCRefExpr to ObjCImplctSetterGetterRefExpr.
Removed an unnecessary loop to get to setters incoming
argument. Added DoxyGen comments. Still more work
to do in this area (WIP).

llvm-svn: 79365
2009-08-18 20:50:23 +00:00
Anders Carlsson 3b848940d7 Only do this for initializers of course.
llvm-svn: 79197
2009-08-16 17:54:29 +00:00
Anders Carlsson b80760bd78 Destroy bound temporaries.
llvm-svn: 79196
2009-08-16 17:50:25 +00:00
Anders Carlsson 5b106a7545 Add an IsInitializer flag to EmitAnyExpr. This is used to prevent temporaries from being destroyed when they're bound to a reference variable.
llvm-svn: 79179
2009-08-16 07:36:22 +00:00
Chris Lattner 19efdd67dd use GetVLASize instead of accessing VLASizeMap directly, this gets an assert if
VLASize isn't populated for the type yet.

llvm-svn: 79057
2009-08-14 23:43:22 +00:00
Owen Anderson 41a750271b Update for LLVM API change.
llvm-svn: 78946
2009-08-13 21:57:51 +00:00
Dan Gohman 43b4484f87 Use the inbounds variant of getelementptr for common pointer arithmetic.
llvm-svn: 78756
2009-08-12 00:33:55 +00:00
Owen Anderson 7ec07a573c Update for LLVM API changes.
llvm-svn: 77638
2009-07-30 23:11:26 +00:00
Mike Stump 658fe02d17 Canonicalize else spacing.
llvm-svn: 77629
2009-07-30 22:28:39 +00:00
Eli Friedman e8caa2a72f Remove bogus "unsupported" case for vectors (which shouldn't
ever trigger).  Add an "unsupported" case that triggers for C++ code.

It would be nice if someone would implement this properly... it 
shouldn't be too hard, but I haven't looked closely at the relevant 
code.

llvm-svn: 77562
2009-07-30 01:10:26 +00:00
Owen Anderson 9793f0e4d7 Update for LLVM API change.
llvm-svn: 77514
2009-07-29 22:16:19 +00:00
Ted Kremenek c23c7e6a51 Change uses of:
Type::getAsReferenceType() -> Type::getAs<ReferenceType>()
  Type::getAsRecordType() -> Type::getAs<RecordType>()
  Type::getAsPointerType() -> Type::getAs<PointerType>()
  Type::getAsBlockPointerType() -> Type::getAs<BlockPointerType>()
  Type::getAsLValueReferenceType() -> Type::getAs<LValueReferenceType>()
  Type::getAsRValueReferenceType() -> Type::getAs<RValueReferenceType>()
  Type::getAsMemberPointerType() -> Type::getAs<MemberPointerType>()
  Type::getAsReferenceType() -> Type::getAs<ReferenceType>()
  Type::getAsTagType() -> Type::getAs<TagType>()
  
And remove Type::getAsReferenceType(), etc.

This change is similar to one I made a couple weeks ago, but that was partly
reverted pending some additional design discussion. With Doug's pending smart
pointer changes for Types, it seemed natural to take this approach.

llvm-svn: 77510
2009-07-29 21:53:49 +00:00
Fariborz Jahanian bb67b827d9 Patch to provide cast of objects in member access
excpression, if needed, and remove some ir-gen code
now unnencessary.

llvm-svn: 77490
2009-07-29 18:40:24 +00:00
Fariborz Jahanian 82e2874270 Code refactoring to define getCXXRecordDeclForPointerType
and use it in several places.

llvm-svn: 77411
2009-07-29 00:44:13 +00:00
Owen Anderson 3cc120a51e Update for LLVM API change.
llvm-svn: 77368
2009-07-28 21:22:35 +00:00
Fariborz Jahanian a399dfae19 More cleanup of data member access and then some.
llvm-svn: 77351
2009-07-28 18:54:57 +00:00
Fariborz Jahanian 5142fbd02e More work toward data member access ir-gen.
llvm-svn: 77332
2009-07-28 17:38:28 +00:00
Owen Anderson b7a2fe6f81 Update for LLVM API change.
llvm-svn: 77012
2009-07-24 23:12:58 +00:00
Anders Carlsson 8af896c10a Move the LLVM field number for bit fields into the BitFieldInfo structure, since it's meaning is completely different than for non-bit fields.
llvm-svn: 76882
2009-07-23 17:01:21 +00:00
Mon P Wang acedf7768f Preserve address space information through member accesses, e.g.,
__attribute__((address_space(1))) struct {int arr[ 3 ]; }  *p1;
   ... = p1->arr[2];  // load from address space 1

llvm-svn: 76717
2009-07-22 03:08:17 +00:00
Ted Kremenek 8a286fbdb9 Per offline discussion with Steve Naroff, add back Type::getAsXXXType() methods
until Doug Gregor's Type smart pointer code lands (or more discussion occurs).
These methods just call the new Type::getAs<XXX> methods, so we still have
reduced implementation redundancy. Having explicit getAsXXXType() methods makes
it easier to set breakpoints in the debugger.

llvm-svn: 76193
2009-07-17 17:50:17 +00:00
Ted Kremenek e3fb4b6524 Add member template 'Type::getAs<T>', which converts a Type* to a respective T*.
This method is intended to eventually replace the individual
Type::getAsXXXType<> methods.

The motivation behind this change is twofold:

1) Reduce redundant implementations of Type::getAsXXXType() methods. Most of
them are basically copy-and-paste.

2) By centralizing the implementation of the getAs<Type> logic we can more
smoothly move over to Doug Gregor's proposed canonical type smart pointer
scheme.

Along with this patch:

a) Removed 'Type::getAsPointerType()'; now clients use getAs<PointerType>.
b) Removed 'Type::getAsBlockPointerTypE()'; now clients use getAs<BlockPointerType>.

llvm-svn: 76098
2009-07-16 19:58:26 +00:00
Steve Naroff 79d1215d83 Remove ASTContext::isObjCObjectPointerType().
Convert all clients to use the new predicate on Type.

llvm-svn: 76076
2009-07-16 15:41:00 +00:00
Owen Anderson 9f98d37612 Update for LLVM API change.
llvm-svn: 75869
2009-07-16 00:14:12 +00:00
Owen Anderson 170229f68d Update for LLVM API change, and contextify a bunch of related stuff.
llvm-svn: 75705
2009-07-14 23:10:40 +00:00
Steve Naroff 7cae42b07a This patch includes a conceptually simple, but very intrusive/pervasive change.
The idea is to segregate Objective-C "object" pointers from general C pointers (utilizing the recently added ObjCObjectPointerType). The fun starts in Sema::GetTypeForDeclarator(), where "SomeInterface *" is now represented by a single AST node (rather than a PointerType whose Pointee is an ObjCInterfaceType). Since a significant amount of code assumed ObjC object pointers where based on C pointers/structs, this patch is very tedious. It should also explain why it is hard to accomplish this in smaller, self-contained patches.

This patch does most of the "heavy lifting" related to moving from PointerType->ObjCObjectPointerType. It doesn't include all potential "cleanups". The good news is additional cleanups can be done later (some are noted in the code). This patch is so large that I didn't want to include any changes that are purely aesthetic.

By making the ObjC types truly built-in, they are much easier to work with (and require fewer "hacks"). For example, there is no need for ASTContext::isObjCIdStructType() or ASTContext::isObjCClassStructType()! We believe this change (and the follow-up cleanups) will pay dividends over time. 

Given the amount of code change, I do expect some fallout from this change (though it does pass all of the clang tests). If you notice any problems, please let us know asap! Thanks.

llvm-svn: 75314
2009-07-10 23:34:53 +00:00
Argyrios Kyrtzidis b4b64ca752 Remove the ASTContext parameter from the attribute-related methods of Decl.
The implementations of these methods can Use Decl::getASTContext() to get the ASTContext.

This commit touches a lot of files since call sites for these methods are everywhere.
I used pre-tokenized "carbon.h" and "cocoa.h" headers to do some timings, and there was no real time difference between before the commit and after it.

llvm-svn: 74501
2009-06-30 02:34:44 +00:00
Nate Begeman ea12f6ebb5 OpenCL 1.0 Support: fix a bug with lvalue swizzles
llvm-svn: 74324
2009-06-26 21:12:50 +00:00
Douglas Gregor 78bd61f661 Move the static DeclAttrs map into ASTContext. Fixes <rdar://problem/6983177>.
llvm-svn: 73702
2009-06-18 16:11:24 +00:00
Chris Lattner 4ca97c3b9e Fix PR4372, another case where non-prototyped functions can prevent
always_inline from working.

llvm-svn: 73273
2009-06-13 00:26:38 +00:00
Eli Friedman 07bbeca406 PR4339: make sure to properly extend/trunc the index of a vector element
insert/extract; the relevant instructions are defined to take only an 
i32.

llvm-svn: 73005
2009-06-06 19:09:26 +00:00
Fariborz Jahanian c6d9800564 A corner case of objc2 gc's write-barrier generation
for the Next runtime.

llvm-svn: 72703
2009-06-01 21:29:32 +00:00
Eli Friedman e32c02114f PR4289: Make sure "&func" has the right LLVM type when "func" is a
K&R-style definition.

llvm-svn: 72690
2009-06-01 10:04:20 +00:00
Anders Carlsson 8eb93e72f7 Emit destructors correctly for temporaries.
llvm-svn: 72655
2009-05-31 00:34:10 +00:00
Anders Carlsson fd2af0cf86 Add lvalue irgen support for CXXBindTemporaryExpr.
llvm-svn: 72649
2009-05-30 23:30:54 +00:00
Anders Carlsson 3be22e27b6 More temporary support.
llvm-svn: 72648
2009-05-30 23:23:33 +00:00
Eli Friedman f7f9f68722 Some small fixes for fields of reference type.
llvm-svn: 72636
2009-05-30 21:09:44 +00:00
Mike Stump df0fe27b66 Fixup the rest of the trivial cases of the codegen of volatile. If
any body can spot codegen bugs with volatile, or knows of any in the
bug database, let me know.

llvm-svn: 72572
2009-05-29 15:46:01 +00:00
Fariborz Jahanian 7551257f00 Change a confusing variable name.
llvm-svn: 72491
2009-05-27 19:48:48 +00:00
Anders Carlsson 4034a95dc8 Handle operator call expressions where the callee is a member function.
llvm-svn: 72458
2009-05-27 04:18:27 +00:00
Anders Carlsson 4ae70ff9a3 Add support for emitting calls to functions that return references (as lvalues only for now)
llvm-svn: 72449
2009-05-27 01:45:47 +00:00
Anders Carlsson 3a9463bfda Rename an EmitCallExpr function to EmitCall to make it clear that it doesn't emit an expr.
llvm-svn: 72446
2009-05-27 01:22:39 +00:00
Mike Stump ec3cbfe8c6 Fixup codegen for volatile structs in the trivial cases (a a=a and a=a=a).
llvm-svn: 72439
2009-05-26 22:03:21 +00:00
Mike Stump 23abd46b79 More volatile fixes. Can't testcase these yet as ultimately volatile
is still ignored.

llvm-svn: 72344
2009-05-23 21:40:07 +00:00
Daniel Dunbar 223db1c9e5 Initialize Obj-C GC attributes when emitting BlockDeclRefExprs.
- Otherwise we may incorrectly miss generation of some write barriers.

llvm-svn: 72313
2009-05-23 02:49:02 +00:00
Eli Friedman c21cb44de2 Handle the remaining unhandled cases in EmitReferenceBindingToExpr.
It would be nice if someone could write an ObjC++ testcase for the case 
of passing a property returning a struct to a function taking a const
reference.

llvm-svn: 72159
2009-05-20 02:31:19 +00:00
Anders Carlsson 02bb7f0ac8 irgen for references to complex rvales (Very important...)
llvm-svn: 72157
2009-05-20 01:35:03 +00:00
Anders Carlsson ad007d44b6 Create a temporary if the lvalue is a bitfield. Reported by Eli.
llvm-svn: 72155
2009-05-20 01:24:22 +00:00
Anders Carlsson 145eae5224 Add support for binding references to scalar rvalues.
llvm-svn: 72153
2009-05-20 01:03:17 +00:00
Anders Carlsson 7d4c083c19 Bind references to lvalues correctly.
llvm-svn: 72150
2009-05-20 00:36:58 +00:00
Anders Carlsson 6f5a015bd9 Add EmitReferenceBindingToExpr. Have EmitCallArg use it for now. Doesn't support anything but at least we don't crash ;)
llvm-svn: 72147
2009-05-20 00:24:07 +00:00
Anders Carlsson 2d228cef50 Improve support for irgen of references.
llvm-svn: 72133
2009-05-19 20:40:02 +00:00
Anders Carlsson 29a1be34b7 Only do the bitcast in EmitStoreOfScalar if the type is a boolean.
llvm-svn: 72125
2009-05-19 19:36:19 +00:00
Anders Carlsson 8370964257 Pass the destination QualType to EmitStoreOfScalar. No functionality change.
llvm-svn: 72118
2009-05-19 18:50:41 +00:00
Mike Stump 18bb9284ff Reflow some comments.
llvm-svn: 71937
2009-05-16 07:57:57 +00:00
Chris Lattner e541ea3a61 implement l-value codegen of comma expr
llvm-svn: 71595
2009-05-12 21:28:12 +00:00
Chris Lattner e0be0dfced push GlobalDecl through enough of the CodeGenModule interfaces
to allow us to support generation of deferred ctors/dtors.
It looks like codegen isn't emitting a call to the dtor in 
member-functions.cpp:test2, but when it does, its body should
get emitted.

llvm-svn: 71594
2009-05-12 21:21:08 +00:00
Fariborz Jahanian 32ff7aeefa Provide basic support for generation of objc2's
objc_assign_global API when assigning to global
objective-c object pointer.

llvm-svn: 70939
2009-05-04 23:27:20 +00:00
Anders Carlsson 1619a5041c Make codegen for constructors work again.
llvm-svn: 70785
2009-05-03 17:47:16 +00:00
Chris Lattner a4185c543e fix PR4067: [Linux kernel] cannot aggregate codegen stmtexpr as lvalue
llvm-svn: 70067
2009-04-25 19:35:26 +00:00
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
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
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 722f424178 Make ObjCInterfaceDecl's const in some more places.
llvm-svn: 69775
2009-04-22 05:08:15 +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 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 41595d43d5 Use getAsPointerType instead of using getCanonicalType directly.
- <rdar://problem/6803995>

llvm-svn: 69435
2009-04-18 08:54:40 +00:00
Chris Lattner c4688d21f7 tidy some code.
llvm-svn: 69360
2009-04-17 17:44:48 +00:00
Anders Carlsson b7f8f594f3 Implement basic code generation of constructor calls. We can now compile:
struct S {
S(int, int);
};

void f() {
S s(10, 10);
}

llvm-svn: 69330
2009-04-17 00:06:03 +00:00
Mike Stump d73e4419f5 Fixup whitespacing.
llvm-svn: 69055
2009-04-14 18:24:37 +00:00
Mike Stump 4c0dc0e48a Use hasAttr instead of getAttr for conditionals.
llvm-svn: 69021
2009-04-14 02:45:29 +00:00
Daniel Dunbar 0ca1660129 Audit __private_extern__ handling.
- Exposed quite a few Sema issues and a CodeGen crash.

 - See FIXMEs in test case, and in SemaDecl.cpp (PR3983).

I'm skeptical that __private_extern__ should actually be a storage
class value. I think that __private_extern__ basically amounts to
  extern A __attribute__((visibility("hidden")))
and would be better off handled (a) as that, or (b) with an extra bit
in the VarDecl.

llvm-svn: 69020
2009-04-14 02:25:56 +00:00
Mike Stump ca5ae66122 Fixup CodeGen for __weak __block variables. Radar 6756266
llvm-svn: 69010
2009-04-14 00:57:29 +00:00
Daniel Dunbar 4184ac847f Update to use hasAttr() instead of getAttr().
- No functionality change.

llvm-svn: 68987
2009-04-13 21:08:27 +00:00
Anders Carlsson 479e6fc7a7 Use the new EmitCallArgs function. No indented functionality change.
llvm-svn: 68652
2009-04-08 23:13:16 +00:00
Sanjiv Gupta 562d68e8db Pointer width on targets like PIC16 is 16-bit, while the valid index size to GEP is only 32 or 64. So promote index to 32 in such cases.
llvm-svn: 68590
2009-04-08 04:16:39 +00:00
Anders Carlsson d8db853243 Remove some dead code.
llvm-svn: 68532
2009-04-07 18:53:02 +00:00
Daniel Dunbar 15894b791b Various fixes to symbols used for Obj-C x86_64 metadata.
- Changed method names to match gcc (categories names still aren't
   mangled in).

 - Expose correct name for class and metadata symbols (although
   -fvisibility=hidden isn't yet correct).

 - Remove several things from llvm.used that didn't need to be there
   (I suspect this can still be trimmed).

 - Don't use asm-prefix extension for _objc_empty_{cache,vtable} (not
   needed).

 - Hide EH type class info with -fvisibility=hidden

 - Change setGlobal[Option]Visibility to not change the visibility of
   functions with internal linkage.

llvm-svn: 68510
2009-04-07 05:48:37 +00:00
Anders Carlsson e5fd6f2227 Add support for calling C++ member functions.
llvm-svn: 68412
2009-04-03 22:50:24 +00:00
Daniel Dunbar bf1fe8c36c Support member reference on ?: of struct type.
llvm-svn: 67603
2009-03-24 02:38:23 +00:00
Chris Lattner 47640221da fix CreateTempAlloca to not set a name on the alloca for temporaries
in release-assert builds.  For automatic variables, explicitly set
a name with setName that does not make a temporary std::string.

This speeds up -emit-llvm-only -disable-free on PR3810 by 4.6%

llvm-svn: 67459
2009-03-22 00:24:14 +00:00
Chris Lattner 0c5e3132aa simplify and comment some code better. Make BindRuntimeGlobals
more optimistic that it will work (optimizing for the common case).

llvm-svn: 67438
2009-03-21 07:48:31 +00:00
Chris Lattner ab17fb2c98 fix the more complex cases by actually codegen'ing the right expr :)
llvm-svn: 67219
2009-03-18 18:30:44 +00:00
Chris Lattner 28bcf1a429 add codegen support for casting an element to a union.
There are some more complex cases (_Complex and structs)
that I'm still working on.

llvm-svn: 67218
2009-03-18 18:28:57 +00:00
Chris Lattner 63d06ab65a teach codegen to handle noop casts as lvalues.
llvm-svn: 67164
2009-03-18 04:02:57 +00:00
Eli Friedman e0a5b8b11f Minor cleanup for choose expressions: add a helper that returns the
chosen sub-expression, rather than just evaluating the condition.

llvm-svn: 66018
2009-03-04 05:52:32 +00:00
Mike Stump 97d01d50d9 Improved ABI compliance for __block variables. No testcases yet as we
still give an unsupported error for them due to the fact this is a
work in progress.

llvm-svn: 66007
2009-03-04 03:23:46 +00:00
Mike Stump 0e425b8200 Push checking down, also, give the user a hit as to which part of the
block literal is causing the problem, instead of the vague reference
to the entire block literal.

llvm-svn: 65798
2009-03-02 03:04:42 +00:00
Mike Stump 1db7d04b71 First cut CodeGen support for __block variables.
llvm-svn: 65688
2009-02-28 09:07:16 +00:00
Chris Lattner d7e7b8e411 first wave of fixes for @encode sema support. This is part of PR3648.
The big difference here is that (like string literal) @encode has 
array type, not pointer type.

llvm-svn: 65391
2009-02-24 22:18:39 +00:00
Fariborz Jahanian 392124c78e We should not generate __weak write barrier on indirect reference
of a pointer to object; This patch does this odd behavior according to
gcc.

llvm-svn: 65334
2009-02-23 18:59:50 +00:00
Fariborz Jahanian 0773533b27 More objc gc work. Match gcc's treatment of ivar access
true a local pointer to objective-c object in generating
write barriers.

llvm-svn: 65290
2009-02-22 18:40:18 +00:00
Fariborz Jahanian a9fecf3f9e local array of objects are non-gc'able.
llvm-svn: 65251
2009-02-21 23:37:19 +00:00
Fariborz Jahanian 10bec1099c Handle case of none gc'able objects regardless of their
type.

llvm-svn: 65205
2009-02-21 00:30:43 +00:00
Daniel Dunbar 27032de34b Shorten; no functionality change.
llvm-svn: 65145
2009-02-20 19:34:33 +00:00
Daniel Dunbar cdbb5e336d Set call attribute for direct calls (i.e. noreturn).
- Remove an unused variant of EmitCallExpr overload.

llvm-svn: 65130
2009-02-20 18:06:48 +00:00
Fariborz Jahanian c86fb5ecb4 More objc gc's ir-gen fixes.
llvm-svn: 65097
2009-02-20 01:14:43 +00:00
Fariborz Jahanian 0f466c746f More objc's gc ir-gen stuff.
llvm-svn: 65077
2009-02-19 23:36:06 +00:00
Fariborz Jahanian 3114e94e10 Generate the conservative objc gc's API for now.
llvm-svn: 65051
2009-02-19 18:29:24 +00:00
Fariborz Jahanian 83e3eea5fc Some code simplification. ir gen for gc'able array
of objects in objc.

llvm-svn: 64992
2009-02-19 00:48:05 +00:00
Douglas Gregor 5f361c9f1e Address Chris's comments regarding C++ name mangling.
llvm-svn: 64984
2009-02-18 23:53:56 +00:00
Fariborz Jahanian 9620769901 Some refactoring and simplificaiotn of objc's gc
ir gen.

llvm-svn: 64954
2009-02-18 21:49:28 +00:00
Fariborz Jahanian 9959eee95d Start generating gc'able code using the new
objc gc type attributes.

llvm-svn: 64935
2009-02-18 18:52:41 +00:00
Fariborz Jahanian 257eac6d0c Cleanup objc's gc attributes code no longer needed.
This make warn-weak-field.m to fail (subject of
a followup patch). 
attr-objc-gc.m no passes.

llvm-svn: 64925
2009-02-18 17:52:36 +00:00
Daniel Dunbar 3d926cbf79 80-cols.
llvm-svn: 64779
2009-02-17 18:31:04 +00:00
Daniel Dunbar 8eb018ab9c Support IRgen of sqrt -> llvm.sqrt, pow -> llvm.pow.
- Define pow[lf]?, sqrt[lf]? as builtins.

 - Add -fmath-errno option which binds to LangOptions.MathErrno

 - Add new builtin flag Builtin::Context::isConstWithoutErrno for
   functions which can be marked as const if errno isn't respected for
   math functions. Sema automatically marks these functions as const
   when they are defined, if MathErrno=0.

 - IRgen uses const attribute on sqrt and pow library functions to
   decide if it can use the llvm intrinsic.

llvm-svn: 64689
2009-02-16 22:43:43 +00:00
Chris Lattner e084c01124 fix volatile handling with ExtVectorElementExpr, so that we
emit two volatile loads for:
typedef __attribute__(( ext_vector_type(4) )) float float4;

float test(volatile float4 *P) {
  return P->x+P->y;
}

llvm-svn: 64683
2009-02-16 22:25:49 +00:00
Chris Lattner b8211f6436 introduce and use a new ExtVectorElementExpr::isArrow method, at Eli's suggestion
llvm-svn: 64681
2009-02-16 22:14:05 +00:00
Chris Lattner 6c7ce109e0 enhance ExtVectorElementExpr to allow V->xxyy to work like (*V).xxyy
llvm-svn: 64667
2009-02-16 21:11:58 +00:00
Douglas Gregor e711f7052e Add hook to add attributes to function declarations that we know
about, whether they are builtins or not. Use this to add the
appropriate "format" attribute to NSLog, NSLogv, asprintf, and
vasprintf, and to translate builtin attributes (from Builtins.def)
into actual attributes on the function declaration.

Use the "printf" format attribute on function declarations to
determine whether we should do format string checking, rather than
looking at an ad hoc list of builtins and "known" function names.

Be a bit more careful about when we consider a function a "builtin" in
C++.

llvm-svn: 64561
2009-02-14 18:57:46 +00:00
Douglas Gregor b9063fc1b3 Implicitly declare certain C library functions (malloc, strcpy, memmove,
etc.) when we perform name lookup on them. This ensures that we
produce the correct signature for these functions, which has two
practical impacts:

  1) When we're supporting the "implicit function declaration" feature
  of C99, these functions will be implicitly declared with the right
  signature rather than as a function returning "int" with no
  prototype. See PR3541 for the reason why this is important (hint:
  GCC always predeclares these functions).
 
  2) If users attempt to redeclare one of these library functions with
  an incompatible signature, we produce a hard error.

This patch does a little bit of work to give reasonable error
messages. For example, when we hit case #1 we complain that we're
implicitly declaring this function with a specific signature, and then
we give a note that asks the user to include the appropriate header
(e.g., "please include <stdlib.h> or explicitly declare 'malloc'"). In
case #2, we show the type of the implicit builtin that was incorrectly
declared, so the user can see the problem. We could do better here:
for example, when displaying this latter error message we say
something like:

  'strcpy' was implicitly declared here with type 'char *(char *, char
  const *)'

but we should really print out a fake code line showing the
declaration, like this:

  'strcpy' was implicitly declared here as:

    char *strcpy(char *, char const *)

This would also be good for printing built-in candidates with C++
operator overloading.

The set of C library functions supported by this patch includes all
functions from the C99 specification's <stdlib.h> and <string.h> that
(a) are predefined by GCC and (b) have signatures that could cause
codegen issues if they are treated as functions with no prototype
returning and int. Future work could extend this set of functions to
other C library functions that we know about.

llvm-svn: 64504
2009-02-13 23:20:09 +00:00
Douglas Gregor 5fec5b0495 Add basic support for C++ name mangling according to the Itanium C++
ABI to the CodeGen library. Since C++ code-generation is so
incomplete, we can't exercise much of this mangling code. However, a
few smoke tests show that it's doing the same thing as GCC. When C++
codegen matures, we'll extend the ABI tester to verify name-mangling
as well, and complete the implementation here.

At this point, the major client of name mangling is in the uses of the
new "overloadable" attribute in C, which allows overloading. Any
"overloadable" function in C (or in an extern "C" block in C++) will
be mangled the same way that the corresponding C++ function would be
mangled.

llvm-svn: 64413
2009-02-13 00:10:09 +00:00
Anders Carlsson 2437cbfa3b Add support for generating block call expressions.
llvm-svn: 64346
2009-02-12 00:39:25 +00:00
Daniel Dunbar 8d9dc4a6d5 Support IRgen of va_arg of structure as l-value.
llvm-svn: 64325
2009-02-11 20:59:32 +00:00
Fariborz Jahanian 21fc74c15a Some refactoring of Ivar offset code gen.
in preparation for nonfragile ivar offset work.

llvm-svn: 64225
2009-02-10 19:02:04 +00:00
Daniel Dunbar 1d425460d5 Add util Emit{LoadOf,StoreTo}Scalar methods to encapsulate conversion
from LLVM memory type to/from LLVM temporary type.
 - No intended functionality change.

llvm-svn: 64191
2009-02-10 00:57:50 +00:00
Daniel Dunbar c79407fc40 Pull CodeGenFunction::GetUndefRValue() out of EmitUnsupportedRValue.
llvm-svn: 63845
2009-02-05 07:09:07 +00:00
Fariborz Jahanian 712bfa6478 ir-gen for nonfragile ivar bitfield access (objc2 nonfragile abi).
llvm-svn: 63644
2009-02-03 19:03:09 +00:00
Fariborz Jahanian c88a70d885 objc2's ir-gen for nonfragile ivar access.
llvm-svn: 63578
2009-02-03 00:09:52 +00:00
Daniel Dunbar bf8c24ad89 Thread CGFunctionInfo construction through CodeGenTypes.
- Inefficient & leaks memory currently, will be cleaned up subsequently.

llvm-svn: 63567
2009-02-02 23:23:47 +00:00
Daniel Dunbar d931a87f90 More ABI API cleanup.
- Lift CGFunctionInfo creation above ReturnTypeUsesSret and
   EmitFunction{Epi,Pro}log.

llvm-svn: 63553
2009-02-02 22:03:45 +00:00
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
Nate Begeman b699c9bf57 Vector codegen improvements
llvm-svn: 62458
2009-01-18 06:42:49 +00:00
Fariborz Jahanian 30e7864661 Patch to implement code gen for aggrgate-valued property used
to access a field of its type.

llvm-svn: 62123
2009-01-12 23:27:26 +00:00
Daniel Dunbar 8429dbc753 Implement EmitUnsupportedRValue to generate an appropriately typed RValue.
llvm-svn: 62004
2009-01-09 20:09:28 +00:00
Daniel Dunbar bb197e439d Give "unsupported" error on calls through block pointers instead of
crashes.

llvm-svn: 61992
2009-01-09 16:50:52 +00:00
Douglas Gregor c7acfdfe9a Add QualifiedDeclRefExpr, which retains additional source-location
information for declarations that were referenced via a qualified-id,
e.g., N::C::value. We keep track of the location of the start of the
nested-name-specifier. Note that the difference between
QualifiedDeclRefExpr and DeclRefExpr does have an effect on the
semantics of function calls in two ways:
  1) The use of a qualified-id instead of an unqualified-id suppresses
     argument-dependent lookup
  2) If the name refers to a virtual function, the qualified-id
  version will call the function determined statically while the
  unqualified-id version will call the function determined dynamically
  (by looking up the appropriate function in the vtable).

Neither of these features is implemented yet, but we do print out
qualified names for QualifiedDeclRefExprs as part of the AST printing.

llvm-svn: 61789
2009-01-06 05:10:23 +00:00
Anders Carlsson e0808df4a5 Add ASTContext::getBaseElementType and use it in CodeGenFunction::EmitArraySubscriptExpr.
llvm-svn: 61303
2008-12-21 03:44:36 +00:00
Anders Carlsson 3d312f8788 Handle VLA indexing
llvm-svn: 61295
2008-12-21 00:11:23 +00:00
Douglas Gregor 2eedc3aa1c Add support for member references (E1.E2, E1->E2) with C++ semantics,
which can refer to static data members, enumerators, and member
functions as well as to non-static data members.

Implement correct lvalue computation for member references in C++. 
Compute the result type of non-static data members of reference type properly.

llvm-svn: 61294
2008-12-20 23:49:58 +00:00
Fariborz Jahanian f8f0c6b1bc Removed a slot in ObjCMemRegExpr used in
code gen which did not belong there.

llvm-svn: 61203
2008-12-18 17:29:46 +00:00
Fariborz Jahanian b517e90662 Code gen. for ivar references; including bitfield
ivars.

llvm-svn: 61043
2008-12-15 20:35:07 +00:00
Chris Lattner 053441f39d Fix rdar://6095061 - gcc allows __builtin_choose_expr as an lvalue
llvm-svn: 60924
2008-12-12 05:35:08 +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