Commit Graph

8057 Commits

Author SHA1 Message Date
James Molloy ecd2edf50c Un-break clang based on r151638 - What was meant to be a trivial variable name change went horribly wrong and I forgot to retest afterwards.
llvm-svn: 151641
2012-02-28 18:23:49 +00:00
James Molloy 051390fffa Correctly track tags and enum members defined in the prototype of a function, and ensure they are properly scoped.
This fixes code such as:

enum e {x, y};
int f(enum {y, x} n) {
  return 0;
}

This finally fixes PR5464 and PR5477.

llvm-svn: 151638
2012-02-28 18:12:11 +00:00
Argyrios Kyrtzidis 3460880674 [AST] When we @synthesize a property with a user-defined ivar name,
make sure to record the source location of the ivar name.
[libclang] When indexing @synthesized objc methods, report the @implementation
as the lexical container.

Fixes rdar://10905472

llvm-svn: 151635
2012-02-28 17:50:39 +00:00
Argyrios Kyrtzidis ceeb19cf18 [AST] Associate the getter/setter methods to a property of a objc class extension.
[libclang] Index the getter/setter methods of a property of a objc class extension.

Fixes rdar://10907597

llvm-svn: 151633
2012-02-28 17:50:28 +00:00
Ted Kremenek 59b10db2bc After numerous requests, have Objective-C 'method declared here' notes mention the actual method. This looks better within an IDE, where text isn't always regurgitated in the presentation of a warning. Fixes radar 10914035.
llvm-svn: 151579
2012-02-27 22:55:11 +00:00
Sebastian Redl aa6feaa7ea Implement a FIXME for conversion sequence distinction. Should fix PR12092.
llvm-svn: 151577
2012-02-27 22:38:26 +00:00
Eli Friedman 84e6e5cd1a Fix a couple bugs in the way we handle array indexes in array bounds checking. Specifically, make sure we don't ignore explicit casts in indexes, and make sure we use unsigned extension/comparisons on indexes. Fixes <rdar://problem/10916006>.
llvm-svn: 151569
2012-02-27 21:21:40 +00:00
Sebastian Redl 6776673f09 Convert initializer lists to temporaries in CreateBuiltinBinOp. Allows assignment of init lists to built-in types and resolves PR12088.
llvm-svn: 151551
2012-02-27 20:34:02 +00:00
Richard Smith 619ecdc80f Ensure that we delete default constructors in the right cases. Don't delete the
default constructor of a union if it has a const member with no user-provided
default constructor.

llvm-svn: 151516
2012-02-27 06:07:25 +00:00
Richard Smith 8e1c932ffb Don't assert when trying to diagnose why a class with a constructor template is
non-trivial.

llvm-svn: 151486
2012-02-26 10:50:32 +00:00
Richard Smith 921bd20ddd Ensure that we delete destructors in the right cases. Specifically:
- variant members with nontrivial destructors make the containing class's
   destructor deleted
 - check for a virtual destructor after checking for overridden methods in the
   base class(es)
 - check for an inaccessible operator delete for a class with a virtual
   destructor.

Do not try to call an anonymous union field's destructor from the destructor of
the containing class.

llvm-svn: 151483
2012-02-26 09:11:52 +00:00
Richard Smith 273c4e9d82 Make sure we don't try to produce a definition of an implicitly-deleted function
llvm-svn: 151478
2012-02-26 07:51:39 +00:00
Richard Smith 0d1f3cb1b5 Special members which are defaulted or deleted on their first declaration are
trivial if the implicit declaration would be. Don't forget to set the Trivial
flag on the special member as well as on the class. It doesn't seem ideal that
we have two separate mechanisms for storing this information, but this patch
does not attempt to address that.

This leaves us in an interesting position where the has_trivial_X trait for a
class says 'yes' for a deleted but trivial X, but is_trivially_Xable says 'no'.
This seems to be what the standard requires.

llvm-svn: 151465
2012-02-26 00:31:33 +00:00
Ahmed Charles b24b9aa298 ArrayRef'ize various functions in the AST/Parser/Sema.
llvm-svn: 151447
2012-02-25 11:00:22 +00:00
Richard Smith 2cca7b5ca9 Accept __has_feature(__feature__) as a synonym for __has_feature(feature) (and
likewise for __has_extension). Patch by Jonathan Sauer!

llvm-svn: 151445
2012-02-25 10:41:10 +00:00
Richard Smith 2a986117e9 Fix r151443 to only apply C++11's exception for non-static data member access
in cases where we would otherwise disallow the access, and add a -Wc++98-compat
diagnostic for this C++11 feature.

llvm-svn: 151444
2012-02-25 10:20:59 +00:00
Richard Smith eae99680e3 PR11956: C++11's special exception for accessing non-static data members from
unevaluated operands applies within member functions, too.

llvm-svn: 151443
2012-02-25 10:04:07 +00:00
Richard Smith 978cc7306c Fix assertion (too few Diag arguments) when diagnosing a deleted operator delete
llvm-svn: 151442
2012-02-25 09:42:26 +00:00
Richard Smith e06a2c1893 Fix a regression from r151117: ADL requires that we attempt to complete any
associated classes, since it can find friend functions declared within them,
but overload resolution does not otherwise require argument types to be
complete.

llvm-svn: 151434
2012-02-25 06:24:24 +00:00
Eli Friedman 2495ab08fc Work-in-progress for lambda conversion-to-block operator. Still need to implement the retain+autorelease outside of ARC, and there's a bug that causes the generated code to crash in ARC (which I think is unrelated to my code, although I'm not completely sure).
llvm-svn: 151428
2012-02-25 02:48:22 +00:00
Eli Friedman 8a78a58188 Improve the diagnostic in ARC mode when a conditional with an Objective-C type and void* is used. <rdar://problem/10486347>.
llvm-svn: 151416
2012-02-25 00:23:44 +00:00
DeLesley Hutchins 5b330db270 Bugfix: bogus warning -- "invalid use of non-static data member",
when a class is forward declared, and the reference to the data
member in question does not occur within a method body.

llvm-svn: 151413
2012-02-25 00:11:55 +00:00
Douglas Gregor 6073dcab38 Implement C++11 [over.match.copy]p1b2, which allows the use of
explicit conversion functions to initialize the argument to a
copy/move constructor that itself is the subject of direct
initialization. Since we don't have that much context in overload
resolution, we end up threading more flags :(.

Fixes <rdar://problem/10903741> / PR10456. 

llvm-svn: 151409
2012-02-24 23:56:31 +00:00
Benjamin Kramer 5f640e35e3 Make helper static.
llvm-svn: 151400
2012-02-24 22:19:42 +00:00
Douglas Gregor 232ee49c7b C++11 [class.ctor]p5 says that
A defaulted default constructor for a class X is defined as deleted if [...]
    -  X is a union and all of its variant members are of const-qualified type.

A pedantic reading therefore says that

 union X { };

has a deleted default constructor, which is both silly and almost
certainly unintended. Pretend as if this this read

    - X is a union with one or more variant members, and all of its
      variant members are of const-qualified type. 

llvm-svn: 151394
2012-02-24 21:25:53 +00:00
Dmitri Gribenko 85e8764254 Fix comment: correct predicate name, reformat comment.
llvm-svn: 151389
2012-02-24 20:03:35 +00:00
Richard Smith fd3da9358f __decltype is a GNU extension, not a C++11 extension.
llvm-svn: 151377
2012-02-24 18:10:23 +00:00
Douglas Gregor 3a08c1cd3b Two minor, related fixes for template instantiation with blocks:
- Make sure that the block expression is instantiation-dependent if the
    block is in a dependent context
  - Make sure that the C++ 'this' expression gets captured even if we
  don't rebuild the AST node during template instantiation. This would
  also have manifested as a bug for lambdas.

Fixes <rdar://problem/10832617>.

llvm-svn: 151372
2012-02-24 17:41:38 +00:00
Matt Beaumont-Gay 47ff1221b1 Sink variable into assert
llvm-svn: 151356
2012-02-24 08:37:56 +00:00
Douglas Gregor f704aded6b Kill a spurious use of hasTrivialDefaultConstructor()
llvm-svn: 151353
2012-02-24 07:48:37 +00:00
Douglas Gregor 29c42f2a25 Implement a new type trait __is_trivially_constructible(T, Args...)
that provides the behavior of the C++11 library trait
std::is_trivially_constructible<T, Args...>, which can't be
implemented purely as a library.

Since __is_trivially_constructible can have zero or more arguments, I
needed to add Yet Another Type Trait Expression Class, this one
handling arbitrary arguments. The next step will be to migrate
UnaryTypeTrait and BinaryTypeTrait over to this new, more general
TypeTrait class.

Fixes the Clang side of <rdar://problem/10895483> / PR12038.

llvm-svn: 151352
2012-02-24 07:38:34 +00:00
Eli Friedman 8195ad7b87 Modernize some code which processes CastExprs to use CastKinds. No intended functional change.
llvm-svn: 151298
2012-02-23 23:04:32 +00:00
Fariborz Jahanian 86f8266b9f objective-c++: Type of an objc string literal is NSString, not 'id'.
// rdar://10907410

llvm-svn: 151296
2012-02-23 22:51:36 +00:00
Aaron Ballman 0c84ebb539 Turned on support for __declspecs: noreturn, noinline, nothrow and naked in MS compatibility mode.
llvm-svn: 151295
2012-02-23 22:46:33 +00:00
Douglas Gregor 2d5aea0f25 Pull the OpaqueValueExpr's source expression into its constructor, so
that we can correctly compute value-dependence of the OVE.

llvm-svn: 151291
2012-02-23 22:17:26 +00:00
Argyrios Kyrtzidis 2e85c5f297 [libclang] Make sure that all top-level decls in a @implementation are
marked as such.

Previously we missed tag declarations; fixes rdar://10902015

llvm-svn: 151283
2012-02-23 21:11:20 +00:00
Fariborz Jahanian 2f0de8bdb9 objective-c default synthesis. classes which adopt protocol properties
must still auto synthesize those propeties which have been redeclared 
in the class. // rdar://10907410

llvm-svn: 151268
2012-02-23 18:21:25 +00:00
Benjamin Kramer 3adbe1ca43 Replace some DenseSets with SmallPtrSets. Apart from the "small" optimization, the current implementation is also a denser.
llvm-svn: 151257
2012-02-23 16:06:01 +00:00
Benjamin Kramer 6b441d62e9 Replace the std::map in the init list checker with a DenseMap to reduce malloc thrashing.
llvm-svn: 151254
2012-02-23 14:48:40 +00:00
Douglas Gregor 1be329d838 Provide the __is_trivially_assignable type trait, which provides
compiler support for the std::is_trivially_assignable library type
trait.

llvm-svn: 151240
2012-02-23 07:33:15 +00:00
Rafael Espindola 8093fdfab1 Two fixes to how we compute visibility:
* Handle some situations where we should never make a decl more visible,
  even when merging in an explicit visibility.

* Handle attributes in members of classes that are explicitly specialized.

Thanks Nico for the report and testing, Eric for the initial review, and dgregor
for the awesome test27 :-)

llvm-svn: 151236
2012-02-23 04:17:32 +00:00
Eli Friedman 91f5ae5022 Try to handle qualifiers more consistently for array InitListExprs. Fixes <rdar://problem/10907510>, and makes the ASTs a bit more self-consistent.
(I've chosen to keep the qualifiers, but it isn't a strong preference; if anyone prefers removing them, please yell.)

llvm-svn: 151229
2012-02-23 02:25:10 +00:00
Aaron Ballman 96e7c09cad Turned on support for __declspec(deprecated) in MS compatibility mode.
llvm-svn: 151225
2012-02-23 01:19:31 +00:00
Sebastian Redl 74b173e5c8 Doug's review comments.
llvm-svn: 151173
2012-02-22 17:38:04 +00:00
Douglas Gregor 2837aa2932 Teach overload resolution to prefer user-defined conversion via a
lambda closure type's function pointer conversion over user-defined
conversion via a lambda closure type's block pointer conversion,
always. This is a preference for more-standard code (since blocks
are an extension)  and a nod to efficiency, since function pointers
don't require any memory management. Fixes PR12063.

llvm-svn: 151170
2012-02-22 17:32:19 +00:00
Sebastian Redl eef474ce1b Fix parsing and processing initializer lists in return statements and as direct member initializers.
llvm-svn: 151155
2012-02-22 10:50:08 +00:00
Hans Wennborg c9dd946852 Warn about non-standard format strings (pr12017)
This adds the -Wformat-non-standard flag (off by default,
enabled by -pedantic), which warns about non-standard
things in format strings (such as the 'q' length modifier,
the 'S' conversion specifier, etc.)

llvm-svn: 151154
2012-02-22 10:17:01 +00:00
Bill Wendling 8eb771d4ca More ArrayRef-ification of methods.
llvm-svn: 151152
2012-02-22 09:51:33 +00:00
Bill Wendling 8ac06afa9b ArrayRef-icize the function arguments.
llvm-svn: 151151
2012-02-22 09:38:11 +00:00
Sebastian Redl e7c31a9a22 Throw away stray CXXDefaultArgExprs. Fixes PR12061.
I think there's a deeper problem here in the way TransformCXXConstructExpr works, but I won't tackle it now.

llvm-svn: 151146
2012-02-22 09:07:21 +00:00