Commit Graph

1681 Commits

Author SHA1 Message Date
Joerg Sonnenberger 5c98e1fb24 Don't warn about address-to-member used as part of initialisation, if
the member expression is in parentheses.

llvm-svn: 158651
2012-06-17 23:10:39 +00:00
Meador Inge 5d3fb22bac Explicitly build __builtin_va_list.
The target specific __builtin_va_list types are now explicitly built instead
of injecting strings into the preprocessor input.

llvm-svn: 158592
2012-06-16 03:34:49 +00:00
Argyrios Kyrtzidis 33b4bfcef5 [AST/libclang] Fix the selector locations that are reported for a
method definition that has its '{' attached to the method name without
a space.

With a method like:

-(id)meth{
.....
}

the logic in ObjCMethodDecl that determined the selector locations got
confused because it was initialized based on an end location for '{' but
that end location changed to '}' after the method was finished.

Fix this by having an immutable end location for the declarator and
for getLocEnd() get the end location from the body itself.

Fixes rdar://11659739.

llvm-svn: 158583
2012-06-16 00:46:02 +00:00
Kaelyn Uhrain b5b17fe9fc Recover when correcting an unknown type name to a keyword like "struct".
llvm-svn: 158573
2012-06-15 23:45:58 +00:00
Kaelyn Uhrain 237c7d33b9 Move isCXXSimpleTypeSpecifier from Parser to Sema and tweak it for wider use.
llvm-svn: 158572
2012-06-15 23:45:51 +00:00
Richard Smith 700537cddf If parsing a trailing-return-type fails, don't pretend we didn't have one at
all. Suppresses follow-on errors mentioned in PR13074.

llvm-svn: 158348
2012-06-12 01:51:59 +00:00
Richard Smith 2b013185f8 PR13064: Store whether an in-class initializer uses direct or copy
initialization, and use that information to produce the right kind of
initialization during template instantiation.

llvm-svn: 158288
2012-06-10 03:12:00 +00:00
Jordan Rose d8d5669435 Warn in ObjC++ when an 'auto' variable deduces type 'id'.
This could happen for cases like this:

- (NSArray *)getAllNames:(NSArray *)images {
  NSMutableArray *results = [NSMutableArray array];
  for (auto img in images) {
    [results addObject:img.name];
  }
  return results;
}

Here the property access will fail because 'img' has type 'id', rather than,
say, NSImage.

This warning will not fire in templated code, since the 'id' could have
come from a template parameter.

llvm-svn: 158239
2012-06-08 22:46:07 +00:00
Richard Smith 337a5a1c3f Allow friend declarations of defaulted special member functions. Only
definitions of such members are prohibited, not mere declarations.

llvm-svn: 158186
2012-06-08 01:30:54 +00:00
Kaelyn Uhrain 1dac08da4b Teach the FixIt in DiagnoseInvalidRedeclaration how to replace the written
nested name specifiers in addition to the function's identifier when the
correction has a different nested name specifier.

llvm-svn: 158178
2012-06-07 23:57:12 +00:00
Kaelyn Uhrain 389e9c2d7c Ignore corrections to functions with bodies when deciding which
correction to use for an invalid function redeclaration.

llvm-svn: 158177
2012-06-07 23:57:08 +00:00
David Blaikie 40ed29730b Revert Decl's iterators back to pointer value_type rather than reference value_type
In addition, I've made the pointer and reference typedef 'void' rather than T*
just so they can't get misused. I would've omitted them entirely but
std::distance likes them to be there even if it doesn't use them.

This rolls back r155808 and r155869.

Review by Doug Gregor incorporating feedback from Chandler Carruth.

llvm-svn: 158104
2012-06-06 20:45:41 +00:00
Fariborz Jahanian 3da28f80e3 objective-c: merge deprecated/unavailable attributes to
the overriding deprecated/unavailable method.
// rdar://11475360

llvm-svn: 158022
2012-06-05 21:14:46 +00:00
David Blaikie 7e6ad46275 Disable -Wunique-enum for anonymous enums.
This is a large class of false positives where anonymous enums are used to
declare constants (see Clang's Diagnostics.h for example). A small number of
true positives could probably be found in this bucket by still warning if the
anonymous enum is used in a declarator (enum { ... } x;) but so far we don't
believe this to be a source of significant benefit so I haven't bothered to
preserve those cases.

General offline review/acknowledgment by rtrieu.

llvm-svn: 157713
2012-05-30 20:45:14 +00:00
Richard Trieu 01cf09302d Add new -Wunique-enum which will warn on enums which all elements have the
same value and were initialized with literals.  Clang will warn on code like
this:

enum A {
  FIRST = 1,
  SECOND = 1
};

llvm-svn: 157666
2012-05-30 01:01:11 +00:00
David Blaikie 3d8edc24c7 Fix indentation.
llvm-svn: 157510
2012-05-26 05:35:39 +00:00
Rafael Espindola 3619104239 Centralize the handling of the "attribute declaration must precede definition"
warning. This also makes us warn on tags, which, ironically, is the only case
gcc warns on.

llvm-svn: 157039
2012-05-18 01:47:00 +00:00
Douglas Gregor 0bf70f4be8 A selector match between two Objective-C methods does *not* guarantee
that the methods have the same number of parameters, although we
certainly assumed this in many places. Objective-C can be insane
sometimes. Fixes <rdar://problem/11460990>.

llvm-svn: 157025
2012-05-17 23:13:29 +00:00
Fariborz Jahanian e1ada58ef4 Remove word 'block' from option and diagnostic I added
in r156825.

llvm-svn: 156831
2012-05-15 17:43:16 +00:00
Fariborz Jahanian 80297b1d90 objective-c nonfragile abi: discourage ivar declarations
in @interface by issuing warning (off by default) under
opt'ed in flag -Winterface-block-ivar. // rdar://10763173

llvm-svn: 156825
2012-05-15 16:33:04 +00:00
Fariborz Jahanian 16d71bb834 objc: allow typedef'ing an id to a pointer to a c-struct only.
// rdar://11356439

llvm-svn: 156788
2012-05-14 22:48:56 +00:00
Rafael Espindola e200f1cb75 Refactor all the
if (Inherited)
    Attr->setInherited(true);

To a central location.

llvm-svn: 156728
2012-05-13 03:25:18 +00:00
Rafael Espindola 9869c3a10f Produce a warning for mismatched section attributes. Completest pr9356.
llvm-svn: 156727
2012-05-13 02:42:42 +00:00
Rafael Espindola 92d49459ab Fix a recent regression with the merging of format attributes.
llvm-svn: 156597
2012-05-11 00:36:07 +00:00
Rafael Espindola c67f223c9e Fix an old (2009) FIXME:
// FIXME: This needs to happen before we merge declarations. Then,
// let attribute merging cope with attribute conflicts.

This was already being done for variables, but for functions we were merging
then first and then applying the attributes. To avoid duplicating merging
logic, some of the helpers in SemaDeclAttr.cpp become methods that can
handle merging two attributes in one decl or inheriting attributes from one
decl to another.

With this change we are now able to produce errors for variables with
incompatible visibility attributes or warn about unused dllimports in
variables.

This changes the attribute list iteration back to being in reverse source
code order, as that matches what decl merging does and avoids differentiating
the two cases is the merge*Attr methods.

llvm-svn: 156531
2012-05-10 02:50:16 +00:00
Fariborz Jahanian 7a055366f2 objective-c. Fixes a 'fixit' where location of
'*' on objective-c class name was misplaced.
// rdar://11311333

llvm-svn: 156517
2012-05-09 21:49:29 +00:00
Richard Trieu 64c51abf7f Update the SelfReferenceChecker. Refactored some of the visitor methods.
Added support for conditional operators and tightened the exclusion of the
unary operator from all operators to only the address of operator.

llvm-svn: 156450
2012-05-09 00:21:34 +00:00
Rafael Espindola 2d243bfe2f Split mergeAvailabilityAttr out of handleAvailabilityAttr. This is important
for having a uniform logic for adding attributes to a decl. This in turn
is needed to fix the FIXME:

  // FIXME: This needs to happen before we merge declarations. Then,
  // let attribute merging cope with attribute conflicts.
  ProcessDeclAttributes(S, NewFD, D,
                        /*NonInheritable=*/false, /*Inheritable=*/true);

The idea is that mergeAvailabilityAttr will become a method. Once attributes
are processed before merging, it will be called from handleAvailabilityAttr to
handle multiple attributes in one decl:

void f(int) __attribute__((availability(ios,deprecated=3.0),
                           availability(ios,introduced=2.0)));

and from SemaDecl.cpp to handle multiple decls:

void f(int) __attribute__((availability(ios,deprecated=3.0)));
void f(int) __attribute__((availability(ios,introduced=2.0)));

As a bonus, use the new structure to diagnose incompatible availability
attributes added to different decls (see included testcases).

llvm-svn: 156269
2012-05-06 19:56:25 +00:00
Douglas Gregor a6c5abb754 Switch RequireLiteralType() off of PartialDiagnostic.
llvm-svn: 156178
2012-05-04 16:48:41 +00:00
Richard Smith 2331bbfb4e Revert most of r154844, which was disabled in r155975. Keep around the
refactorings in that revision, and some of the subsequent bugfixes, which
seem to be relevant even without delayed exception specification parsing.

llvm-svn: 156031
2012-05-02 22:22:32 +00:00
Kaelyn Uhrain 7179205f49 Try harder to recognize hidden tag type names in potential declarations instead
of giving unhelpful errors about undeclared identifers and missing semicolons.

llvm-svn: 155965
2012-05-02 00:11:40 +00:00
David Blaikie 7665a62cf7 Add FixItHint for -Wnull-conversion to initialize with an appropriate literal.
Reviewed by Doug Gregor.

llvm-svn: 155839
2012-04-30 18:27:22 +00:00
Douglas Gregor 205b068975 HandleDeclarator() returns NULL for semantic disasters. Deal with it
when we're in an Objective-C container context. Fixes
<rdar://problem/11286701>.

llvm-svn: 155836
2012-04-30 18:13:01 +00:00
David Blaikie 2d7c57ec1d Remove the ref/value inconsistency in filter_decl_iterator.
filter_decl_iterator had a weird mismatch where both op* and op-> returned T*
making it difficult to generalize this filtering behavior into a reusable
library of any kind.

This change errs on the side of value, making op-> return T* and op* return
T&.

(reviewed by Richard Smith)

llvm-svn: 155808
2012-04-30 02:36:29 +00:00
Kaelyn Uhrain 3fe3f85769 Imrpove the note text for when a non-type decl hides a tag type
llvm-svn: 155723
2012-04-27 18:26:49 +00:00
Kaelyn Uhrain 031643ef48 Add note to help explain why a tag such as 'struct' is needed to refer
to a given type, when the reason is that there is a non-type decl with
the same name.

llvm-svn: 155677
2012-04-26 23:36:17 +00:00
Richard Smith 84973e56e3 Fix regression in r154844. If necessary, defer computing adjusted destructor
exception specifications in C++11 until after we've parsed the exception
specifications for nested classes.

llvm-svn: 155293
2012-04-21 18:42:51 +00:00
Richard Smith 79a52e5709 PR12569: Instantiate exception specifications of explicit instantiations
and explicit specializations of function templates appropriately.

llvm-svn: 154956
2012-04-17 22:30:01 +00:00
Douglas Gregor 433e05306f Implement the last part of C++ [class.mem]p2, delaying the parsing of
exception specifications on member functions until after the closing
'}' for the containing class. This allows, for example, a member
function to throw an instance of its own class. Fixes PR12564 and a
fairly embarassing oversight in our C++98/03 support.

llvm-svn: 154844
2012-04-16 18:27:27 +00:00
Douglas Gregor 3024f07c12 Implement C++11 [expr.prim.general]p3, which permits the use of 'this'
in the declaration of a non-static member function after the
(optional) cv-qualifier-seq, which in practice means in the exception
specification and late-specified return type. 

The new scheme here used to manage 'this' outside of a member function
scope is more general than the Scope-based mechanism previously used
for non-static data member initializers and late-parsesd attributes,
because it can also handle the cv-qualifiers on the member
function. Note, however, that a separate pass is required for static
member functions to determine whether 'this' was used, because we
might not know that we have a static function until after declaration
matching.

Finally, this introduces name mangling for 'this' and for the implicit
'this', which is intended to match GCC's mangling. Independent
verification for the new mangling test case would be appreciated.

Fixes PR10036 and PR12450.

llvm-svn: 154799
2012-04-16 07:05:22 +00:00
Richard Smith 822698412b PR12500: Improve the wording of the diagnostic for a redefinition of a name
in the wrong namespace scope. Patch by Jonathan Sauer!

llvm-svn: 154656
2012-04-13 04:07:40 +00:00
DeLesley Hutchins 6f86004cbc Fixed scoping error for late parsed attributes in nested classes.
llvm-svn: 154173
2012-04-06 15:10:17 +00:00
Kaelyn Uhrain f4657d5bd7 Replace the workaround from r153445 with a proper fix.
Infinite recursion was happening when DiagnoseInvalidRedeclaration
called ActOnFunctionDeclarator to check if a typo correction works when
the correction was just to the nested-name-specifier because the wrong
DeclContext was being passed in. Unlike a number of functions
surrounding typo correction, the DeclContext passed in for a function is
the context of the function name after applying any nested name
specifiers, not the lexical DeclContext where the
function+nested-name-specifier appears.

llvm-svn: 153962
2012-04-03 18:20:11 +00:00
Richard Smith cf8ec8dad6 Implement DR1402: if a field or base class is not movable, the derived class's
move constructor/move assignment operator are not declared, rather than being
defined as deleted, so move operations on the derived class fall back to
copying rather than moving.

If a move operation on the derived class is explicitly defaulted, the
unmovable subobject will be copied instead of being moved.

llvm-svn: 153883
2012-04-02 18:40:40 +00:00
Richard Smith 23d55873cb Basic semantic analysis support for inheriting constructor declarations in
dependent contexts.

llvm-svn: 153858
2012-04-02 01:30:27 +00:00
Douglas Gregor b7d17ddbf9 Unify and fix our checking of C++ [dcl.meaning]p1's requirements
concerning qualified declarator-ids. We now diagnose extraneous
qualification at namespace scope (which we had previously missed) and
diagnose these qualification errors for all kinds of declarations; it
was rather uneven before. Fixes <rdar://problem/11135644>.

llvm-svn: 153577
2012-03-28 16:01:27 +00:00
Douglas Gregor b11f94590c When diagnosing an invalid out-of-line redeclaration, don't permit
typo correction to introduce a nested-name-specifier; we aren't
prepared to handle it here. Fixes PR12297 / <rdar://problem/11075219>.

llvm-svn: 153445
2012-03-26 16:54:18 +00:00
Richard Smith 258a744bbd Delay checking of dependent underlying types for redeclarations of member
enumerations in templates until the template is instantiated.

llvm-svn: 153426
2012-03-26 04:08:46 +00:00
Richard Smith b66d77793f When defining a forward-declared enum, don't try to attach the definition to
a previous declaration if the redeclaration is invalid. That way lies madness.
Fixes a crash-on-invalid reported by Abramo.

llvm-svn: 153349
2012-03-23 23:09:08 +00:00
Richard Smith 7d137e3b98 Support for definitions of member enumerations of class templates outside the
class template's definition, and for explicit specializations of such enum
members.

llvm-svn: 153304
2012-03-23 03:33:32 +00:00