Commit Graph

1145 Commits

Author SHA1 Message Date
John McCall 29cb2fdbc1 When deciding whether to complain about the type of a boolean condition, use
the type of the expression *after* array/function decay.

llvm-svn: 120895
2010-12-04 06:09:13 +00:00
John McCall 34376a68c4 Although we currently have explicit lvalue-to-rvalue conversions, they're
not actually frequently used, because ImpCastExprToType only creates a node
if the types differ.  So explicitly create an ICE in the lvalue-to-rvalue
conversion code in DefaultFunctionArrayLvalueConversion() as well as several
other new places, and consistently deal with the consequences throughout the
compiler.

In addition, introduce a new cast kind for loading an ObjCProperty l-value,
and make sure we emit those nodes whenever an ObjCProperty l-value appears
that's not on the LHS of an assignment operator.

This breaks a couple of rewriter tests, which I've x-failed until future
development occurs on the rewriter.

Ted Kremenek kindly contributed the analyzer workarounds in this patch.

llvm-svn: 120890
2010-12-04 03:47:34 +00:00
Peter Collingbourne 0b69e1a628 Implement -cl-single-precision-constant
llvm-svn: 120877
2010-12-04 01:50:56 +00:00
Fariborz Jahanian ecbbb6e9ba Diagnose when accessing property in a class method and
no property accessor class method to be found, instead of
crashing in IRGen. // rdar://8703553

llvm-svn: 120855
2010-12-03 23:37:08 +00:00
Abramo Bagnara 21e9d860b5 Fixed typo.
llvm-svn: 120839
2010-12-03 21:39:42 +00:00
John McCall b7bd14fa08 Simplify the ASTs by consolidating ObjCImplicitGetterSetterExpr and ObjCPropertyRefExpr
into the latter.

llvm-svn: 120643
2010-12-02 01:19:52 +00:00
Bob Wilson 01856f38c2 Swap order of checking for compatible vector types.
Check for compatible gcc, Altivec and Neon vectors before handling the
lax-vector-conversions case.  Otherwise there is no way to avoid the
warnings from -Wvector-conversions.

llvm-svn: 120633
2010-12-02 00:25:15 +00:00
John McCall f3735e01ce Restore the lvalue-to-rvalue conversion patch with a minimal fix.
llvm-svn: 120555
2010-12-01 04:43:34 +00:00
John McCall 4f22c9de48 L-value to r-value conversion is not ready for prime-time.
llvm-svn: 120433
2010-11-30 17:58:55 +00:00
Fariborz Jahanian e8473c2feb Such function decls,as objc's objc_msgSend, builtins in
a specific language. We are adding such language info. by
extensing Builtins.def and via a language flag added
to LIBBUILTIN/BUILTIN and check for that when deciding
a name is builtin or not. Implements //rdar://8689273.

llvm-svn: 120429
2010-11-30 17:35:24 +00:00
John McCall 824fd1dcff Introduce an r-value to l-value cast kind. I'm not promising anything
about the reliability of this yet.

llvm-svn: 120422
2010-11-30 10:13:06 +00:00
Nico Weber ebd45a004d Fix bug in r120299 spotted by dgregor.
llvm-svn: 120389
2010-11-30 04:44:33 +00:00
Nico Weber 44887f69d5 Always use a function's decl context when building default arguments. Fixes http://http://llvm.org/pr8479.
llvm-svn: 120299
2010-11-29 18:19:25 +00:00
Nico Weber dcf6fc5dc4 Revert parts of r120266 that I did not mean to commit
llvm-svn: 120267
2010-11-28 22:58:38 +00:00
Nico Weber 20c9f1db48 Minor whitespace and comment fixes. No functionality change.
llvm-svn: 120266
2010-11-28 22:53:37 +00:00
Sebastian Redl 346203105f Allow access to non-static members without an object in sizeof expressions, in C++0x. Patch by Jakub Wieczorek.
llvm-svn: 120182
2010-11-26 16:28:07 +00:00
John McCall 086a464e24 Switch a lot of call-sites over to using the new value-kind calculations.
llvm-svn: 120084
2010-11-24 05:12:34 +00:00
John McCall feb624a435 A few tweaks to the value-kind computation:
- Default argument expressions pick up the value kind of the incoming
   expression, not the value kind of the parameter it initializes.
 - When building a template argument for substitution, A::x is an rvalue
   if x is an instance method.
 - Anonymous struct/union paths pick up value kind the same way that
   normal member accesses do;  extract out a common code path for this.

Enable the value-kind assertion, now that it passes self-host.

llvm-svn: 120055
2010-11-23 20:48:44 +00:00
Benjamin Kramer 3959370c92 Fix a bunch of IndirectFieldDecl-related warnings.
- Negative ChainingSize doesn't make sense, make it unsigned.

llvm-svn: 119943
2010-11-21 14:11:41 +00:00
Francois Pichet 783dd6ece4 Major anonymous union/struct redesign.
A new AST node is introduced:
   def IndirectField : DDecl<Value>;
IndirectFields are injected into the anonymous's parent scope and chain back to
the original field. Name lookup for anonymous entities now result in an
IndirectFieldDecl instead of a FieldDecl.
There is no functionality change, the code generated should be the same.

llvm-svn: 119919
2010-11-21 06:08:52 +00:00
Fariborz Jahanian e7d62020a7 objc_msgSend is not a builtin type in non-objc mode.
Fixes //rdar://8686888

llvm-svn: 119813
2010-11-19 18:16:46 +00:00
John McCall 4bc41aee2b Add an assertion, fix a whole bunch of bugs, comment the assertion
out because there are still bugs left.

llvm-svn: 119722
2010-11-18 19:01:18 +00:00
John McCall 7decc9e4ea Calculate the value kind of an expression when it's created and
store it on the expression node.  Also store an "object kind",
which distinguishes ordinary "addressed" l-values (like
variable references and pointer dereferences) and bitfield,
@property, and vector-component l-values.

Currently we're not using these for much, but I aim to switch
pretty much everything calculating l-valueness over to them.
For now they shouldn't necessarily be trusted.

llvm-svn: 119685
2010-11-18 06:31:45 +00:00
Anton Yartsev 3f8f2886c1 comparison of AltiVec vectors now gives bool result (fix for 7533)
llvm-svn: 119678
2010-11-18 03:19:30 +00:00
Fariborz Jahanian 8046af7d50 Warn if direct accessing synthesized ivar backing the property in
nonofragile-abi2. Fixes //rdar://8673791

llvm-svn: 119543
2010-11-17 19:41:23 +00:00
Argyrios Kyrtzidis 56e879d1da Don't emit warn_logical_and_in_logical_or for cases like "a && b || 0".
llvm-svn: 119540
2010-11-17 19:18:19 +00:00
Argyrios Kyrtzidis b94e5a33b3 Don't emit warn_logical_and_in_logical_or for macros. Fixes rdar://8678458
llvm-svn: 119537
2010-11-17 18:54:22 +00:00
Argyrios Kyrtzidis 14a96625b8 Don't warn for parentheses for the '&&' inside '||' for cases like:
assert(a || b && "bad");

since this is safe. This way we avoid a big source of such warnings which in this case are practically useless.

Note that we don't handle *all* cases where precedence wouldn't matter because of constants since
this is a bit costly to check, and IMO clarifying precedence with parentheses is good for
readability in general.

llvm-svn: 119533
2010-11-17 18:26:36 +00:00
Argyrios Kyrtzidis f89a56c74b Warn about arg1 && arg2 || arg3, as GCC 4.3+ does. Fixes rdar://8659922
llvm-svn: 119381
2010-11-16 21:00:12 +00:00
Fariborz Jahanian a3e54bd33e Implements __block API for c++ objects. There is still
issue with runtime which I am discussing it with Blaine.
This is wip (so no test yet).

llvm-svn: 119368
2010-11-16 19:29:39 +00:00
John McCall 29600e160e Kill off the remaining places which generate CK_Unknown casts.
llvm-svn: 119326
2010-11-16 02:32:08 +00:00
John McCall 3065d046b5 Yes, vector conversions are bitcasts.
llvm-svn: 119141
2010-11-15 10:08:00 +00:00
John McCall 8cb679e4e1 Assorted work leading towards the elimination of CK_Unknown.
llvm-svn: 119138
2010-11-15 09:13:47 +00:00
John McCall d764625448 Add a few more complex-related cast kinds that arise due to arbitrary
implicit conversions;  the last batch was specific to promotions.
I think this is the full set we need.  I do think dividing the cast
kinds into floating and integral is probably a good idea.

Annotate a *lot* more C casts with useful cast kinds.

llvm-svn: 119036
2010-11-14 08:17:51 +00:00
John McCall c5e62b47af Introduce five new cast kinds for various conversions into and
between complex types.

llvm-svn: 118994
2010-11-13 09:02:35 +00:00
John McCall d005ac937e Bring UsualArithmeticConversionsType back into Sema and cast the
operands appropriately.  There are a lot of missing complex-related
cast kinds.

llvm-svn: 118993
2010-11-13 08:17:45 +00:00
John McCall e84af4e486 Introduce a null-to-pointer implicit cast kind.
llvm-svn: 118966
2010-11-13 01:35:44 +00:00
Fariborz Jahanian 2a5deb56a4 Adding couple of Block API, a bug fix and
a test change, all for blocks. wip.

llvm-svn: 118745
2010-11-11 00:11:38 +00:00
Douglas Gregor 0124e9ba9a Attempt to resolve overloaded functions in comma expressions and
conditional operators. Fixes PR7863.

llvm-svn: 118631
2010-11-09 21:07:58 +00:00
Douglas Gregor 928479e727 Revert the fix for PR8013.
That bug concerned the well-formedness of code such as (&ovl)(a, b,
c). GCC rejects the code, while EDG accepts it. On further study of the
standard, I see no support for EDG's position: in particular, C++
[over.over] does not list this as a context where we can take the
address of an overloaded function, C++ [over.call.func] does not
reference the address-of operator at any point, and C++ [expr.call]
claims that the function argument in a call is either a function
lvalue or a pointer-to-function; (&ovl) is neither.

llvm-svn: 118620
2010-11-09 20:03:54 +00:00
Douglas Gregor 8f225bb508 Handle overload resolution when calling an overloaded function set
with, e.g., (&f)(a, b, c). Fixes PR8013.

llvm-svn: 118508
2010-11-09 16:13:15 +00:00
Argyrios Kyrtzidis 8566356acb When building a compound literal, check that the base element of the array is complete.
Fixes rdar://8620582 & http://llvm.org/PR7905

llvm-svn: 118428
2010-11-08 19:14:19 +00:00
Douglas Gregor 1ccc8416a0 Remove broken support for variadic templates, along with the various
abstractions (e.g., TemplateArgumentListBuilder) that were designed to
support variadic templates. Only a few remnants of variadic templates
remain, in the parser (parsing template type parameter packs), AST
(template type parameter pack bits and TemplateArgument::Pack), and
Sema; these are expected to be used in a future implementation of
variadic templates.

But don't get too excited about that happening now.

llvm-svn: 118385
2010-11-07 23:05:16 +00:00
Anders Carlsson e981a8c231 Expressions of type std::nullptr_t can be used as sentinels.
llvm-svn: 118276
2010-11-05 15:21:33 +00:00
Anders Carlsson a95069c52f It's OK to use nullptr in relational operators if the other side is a null pointer constant.
llvm-svn: 118234
2010-11-04 03:17:43 +00:00
Douglas Gregor 15417cfa56 Improve source-location information for CXXConstructExpr nodes, by
ensuring that they cover all of their child nodes. There's still a
clang_getCursor()-related issue with CXXFunctionalCastExprs with
CXXConstructExprs as children (see FIXME in the test case); I'll look
at that separately.

llvm-svn: 118132
2010-11-03 00:35:38 +00:00
Douglas Gregor 05fcf84d14 Teach code completion to provide property results when the property
can be used to automatically synthesize an ivar.

llvm-svn: 118052
2010-11-02 20:36:02 +00:00
Argyrios Kyrtzidis ca76629618 Emit error when using a bound member function for something other than calling it.
Also avoids IRGen crashes due to accepting invalid code.

llvm-svn: 117943
2010-11-01 18:49:26 +00:00
Douglas Gregor b524d906fe Require that the types of the parameters of a block literal are complete.
llvm-svn: 117942
2010-11-01 18:37:59 +00:00
Fariborz Jahanian dd6907bd77 Decay array/function types of a statement-expression.
// rdar: // 8600553.

llvm-svn: 117484
2010-10-27 20:44:00 +00:00