Commit Graph

559 Commits

Author SHA1 Message Date
John McCall 46c4622350 Refine r251469 to give better (and more localizable) diagnostics
for all the reasons that ARC makes things implicitly unavailable.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@251496 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-28 05:03:19 +00:00
Bob Wilson 2fd266bcf9 Be slightly more permissive when checking for type-erased blocks.
This is a patch from Doug that was inadvertently omitted from r241543.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@249116 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-02 01:05:29 +00:00
Aaron Ballman 26440abcdd Silence a "not all control paths return a value" warning from MSVC. Should also silence a -Wreturn-type warning. NFC intended.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@243109 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-24 12:47:27 +00:00
Alex Denisov 7fe6f5798b Cleanup ObjCInterfaceDecl lookup for ObjC literals
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@243092 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-24 05:09:40 +00:00
Douglas Gregor ffad82b290 Implement the Objective-C __kindof type qualifier.
The __kindof type qualifier can be applied to Objective-C object
(pointer) types to indicate id-like behavior, which includes implicit
"downcasting" of __kindof types to subclasses and id-like message-send
behavior. __kindof types provide better type bounds for substitutions
into unspecified generic types, which preserves more type information.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@241548 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-07 03:58:42 +00:00
Douglas Gregor a6620f3825 Substitute type arguments into uses of Objective-C interface members.
When messaging a method that was defined in an Objective-C class (or
category or extension thereof) that has type parameters, substitute
the type arguments for those type parameters. Similarly, substitute
into property accesses, instance variables, and other references.

This includes general infrastructure for substituting the type
arguments associated with an ObjCObject(Pointer)Type into a type
referenced within a particular context, handling all of the
substitutions required to deal with (e.g.) inheritance involving
parameterized classes. In cases where no type arguments are available
(e.g., because we're messaging via some unspecialized type, id, etc.),
we substitute in the type bounds for the type parameters instead.

Example:

  @interface NSSet<T : id<NSCopying>> : NSObject <NSCopying>
  - (T)firstObject;
  @end

  void f(NSSet<NSString *> *stringSet, NSSet *anySet) {
    [stringSet firstObject]; // produces NSString*
    [anySet firstObject]; // produces id<NSCopying> (the bound)
  }

When substituting for the type parameters given an unspecialized
context (i.e., no specific type arguments were given), substituting
the type bounds unconditionally produces type signatures that are too
strong compared to the pre-generics signatures. Instead, use the
following rule:

  - In covariant positions, such as method return types, replace type
    parameters with “id” or “Class” (the latter only when the type
    parameter bound is “Class” or qualified class, e.g,
    “Class<NSCopying>”)
  - In other positions (e.g., parameter types), replace type
    parameters with their type bounds.
  - When a specialized Objective-C object or object pointer type
    contains a type parameter in its type arguments (e.g.,
    NSArray<T>*, but not NSArray<NSString *> *), replace the entire
    object/object pointer type with its unspecialized version (e.g.,
    NSArray *).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@241543 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-07 03:57:53 +00:00
Douglas Gregor 06714fc31e Handle Objective-C type arguments.
Objective-C type arguments can be provided in angle brackets following
an Objective-C interface type. Syntactically, this is the same
position as one would provide protocol qualifiers (e.g.,
id<NSCopying>), so parse both together and let Sema sort out the
ambiguous cases. This applies both when parsing types and when parsing
the superclass of an Objective-C class, which can now be a specialized
type (e.g., NSMutableArray<T> inherits from NSArray<T>).

Check Objective-C type arguments against the type parameters of the
corresponding class. Verify the length of the type argument list and
that each type argument satisfies the corresponding bound.

Specializations of parameterized Objective-C classes are represented
in the type system as distinct types. Both specialized types (e.g.,
NSArray<NSString *> *) and unspecialized types (NSArray *) are
represented, separately.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@241542 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-07 03:57:35 +00:00
Douglas Gregor 5df68d34cd Parsing, semantic analysis, and AST for Objective-C type parameters.
Produce type parameter declarations for Objective-C type parameters,
and attach lists of type parameters to Objective-C classes,
categories, forward declarations, and extensions as
appropriate. Perform semantic analysis of type bounds for type
parameters, both in isolation and across classes/categories/extensions
to ensure consistency.

Also handle (de-)serialization of Objective-C type parameter lists,
along with sundry other things one must do to add a new declaration to
Clang.

Note that Objective-C type parameters are typedef name declarations,
like typedefs and C++11 type aliases, in support of type erasure.

Part of rdar://problem/6294649.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@241541 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-07 03:57:15 +00:00
Alex Denisov 3849076ca6 [ObjC] Add NSValue support for objc_boxed_expressions
Patch extends ObjCBoxedExpr to accept records (structs and unions):

typedef struct __attribute__((objc_boxable)) _Color {
  int r, g, b;
} Color;

Color color;
NSValue *boxedColor = @(color); // [NSValue valueWithBytes:&color objCType:@encode(Color)];



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@240761 91177308-0d34-0410-b5e6-96231b3b80d8
2015-06-26 05:28:36 +00:00
Alexander Kornienko 8ca7705aa3 Revert r240270 ("Fixed/added namespace ending comments using clang-tidy").
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@240353 91177308-0d34-0410-b5e6-96231b3b80d8
2015-06-22 23:07:51 +00:00
Alexander Kornienko ac58acc7f2 Fixed/added namespace ending comments using clang-tidy. NFC
The patch is generated using this command:

  $ tools/extra/clang-tidy/tool/run-clang-tidy.py -fix \
      -checks=-*,llvm-namespace-comment -header-filter='llvm/.*|clang/.*' \
      work/llvm/tools/clang

To reduce churn, not touching namespaces spanning less than 10 lines.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@240270 91177308-0d34-0410-b5e6-96231b3b80d8
2015-06-22 09:47:44 +00:00
Douglas Gregor 109dad2dfc Introduced pragmas for audited nullability regions.
Introduce the clang pragmas "assume_nonnull begin" and "assume_nonnull
end" in which we make default assumptions about the nullability of many
unannotated pointers:

  - Single-level pointers are inferred to __nonnull
  - NSError** in a (function or method) parameter list is inferred to
    NSError * __nullable * __nullable.
  - CFErrorRef * in a (function or method) parameter list is inferred
    to CFErrorRef __nullable * __nullable.
  - Other multi-level pointers are never inferred to anything.

Implements rdar://problem/19191042.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@240156 91177308-0d34-0410-b5e6-96231b3b80d8
2015-06-19 18:25:57 +00:00
Douglas Gregor e3a960065d Extend type nullability qualifiers for Objective-C.
Introduce context-sensitive, non-underscored nullability specifiers
(nonnull, nullable, null_unspecified) for Objective-C method return
types, method parameter types, and properties.

Introduce Objective-C-specific semantics, including computation of the
nullability of the result of a message send, merging of nullability
information from the @interface of a class into its @implementation,
etc .

This is the Objective-C part of rdar://problem/18868820.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@240154 91177308-0d34-0410-b5e6-96231b3b80d8
2015-06-19 18:14:38 +00:00
Fariborz Jahanian d6104dcab5 [Objective-C Sema]This patch fixes the warning when clang issues
"multiple methods named '<selector>' found" warning by noting 
the method that is actualy used. It also cleans up and refactors
code in this area and selects a method that matches actual arguments
in case of receiver being a forward class object.
rdar://19265430


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235023 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-15 17:26:21 +00:00
Fariborz Jahanian f6543787b0 [Objective-C Sema] Fixes a typo which did not allow
bridge casting to super class of object's bridge type.
rdar://18311183


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@234652 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-10 22:07:47 +00:00
Fariborz Jahanian 7e9f4eeaf9 [Objective-C Sema] It is permissable to bridge cast to 'id'
of a CFType bridged to some unknown Objective-C type. 
rdar://20113785


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@234545 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-09 23:39:53 +00:00
Chandler Carruth 1ede25994e [Modules] Make Sema's map of referenced selectors have a deterministic
order based on order of insertion.

This should cause both our warnings about these and the modules
serialization to be deterministic as a consequence.

Found by inspection.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@233343 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-27 00:55:05 +00:00
Fariborz Jahanian 45e5caa859 [Objective-C Sema]. Remove -Wreceiver-is-weak warning.
It is incorrect and better warning is issued under
-Warc-repeated-use-of-weak. rdar://16316934.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@231851 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-10 21:28:33 +00:00
John McCall e9bbc1a72b Recognize objc_bridge(id) on bridged casts to CF types.
Fixes <rdar://20107345>.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@231814 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-10 18:41:23 +00:00
Alex Denisov 5dc6c6cd87 New ObjC warning: circular containers.
This commit adds new warning to prevent user from creating 'circular containers'.

Mutable collections from NSFoundation allows user to add collection to itself, e.g.: 

NSMutableArray *a = [NSMutableArray new]; 
[a addObject:a]; 

The code above leads to really weird behaviour (crashes, 'endless' recursion) and 
retain cycles (collection retains itself) if ARC enabled.

Patch checks the following collections: 
  - NSMutableArray, 
  - NSMutableDictionary, 
  - NSMutableSet, 
  - NSMutableOrderedSet, 
  - NSCountedSet. 



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@231265 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-04 17:55:52 +00:00
Ben Langmuir b378995a9f Allow (Object *)kMyGlobalCFObj casts without bridging
Previously we allowed these casts only for constants declared in system
headers, which we assume are retain/release-neutral. Now also allow them
for constants in user headers, treating them as +0.  Practically, this
means that we will now allow:
id x = (id)kMyGlobalConst;

But unlike with system headers we cannot mix them with +1 values:
id y = (id)(b ? kMyGlobalConst : [Obj newValAtPlusOne]); // error
id z = (id)(b ? kSystemGlobalConst: [Obj newValAtPlusOne]); // OK

Thanks to John for suggesting this improvement.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@230534 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-25 20:09:06 +00:00
Alex Denisov 414133a38e Fix crash when clang tries to build NSNumber literal after forward declaration
Bug report: http://llvm.org/bugs/show_bug.cgi?id=22561

Clang tries to create ObjCBoxedExpression of type 'NSNumber'
when 'NSNumber' has only forward declaration, this cause a crash later, 
when 'Sema' refers to a nil QualType of the whole expression.
Please, refer to the bug report for the better explanation.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@229402 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-16 16:17:05 +00:00
Fariborz Jahanian 8574a588fc Patch fixes PR21932 crash on invalid code. Using
property-dot syntax on 'super' with no super
class. Patch by Jason Haslam.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@226578 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-20 16:53:34 +00:00
Nico Weber 7b38956489 Address review feedback on r221933.
Remove ObjCMethodList::Count, instead store a "has more than one decl" bit in
the low bit of the ObjCMethodDecl pointer, using a PointerIntPair.

Most of this patch is replacing ".Method" with ".getMethod()".

No intended behavior change.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@224876 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-27 03:58:08 +00:00
Fariborz Jahanian bb657de5a6 [Objective-C]. This patch extends objc_bridge attribute to support objc_bridge(id).
This means that a pointer to the struct type to which the attribute appertains 
is a CF type (and therefore an Objective-C object of some type), but not of any 
specific class. rdar://19157264


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@224072 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-11 22:56:26 +00:00
Sylvestre Ledru 401135c22d Fix the indentation: Nesting level does not match indentation (CID 1254863)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@222152 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-17 18:26:39 +00:00
Fariborz Jahanian 5a9e570023 Objective-C. Fixes a regression caused by implementation
of new warning for deprecated method call for receiver
of type 'id'. This addresses rdar://18960378 where
unintended warnings being issued.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@221933 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-13 22:27:05 +00:00
Fariborz Jahanian 90d23dda98 [Objective-C Sema]. Issue availability/deprecated warning when
there is a uinque method found when message is sent to receiver 
of 'id' type. // rdar://18848183


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@221562 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-07 23:51:15 +00:00
Fariborz Jahanian 951324d0ef Objective-C. revert patch for rdar://17554063.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@220812 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-28 18:28:16 +00:00
Fariborz Jahanian c3ceec3848 [Objective-C]. revert r220740,r220727
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@220802 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-28 17:26:21 +00:00
Fariborz Jahanian 23b7656b34 Objective-C ARC [qoi]. Issue diagnostic if __bridge casting
to C type a collection literal. rdar://18768214


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@220727 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-27 22:33:06 +00:00
Kaelyn Takata 07ccb0381a Pass around CorrectionCandidateCallbacks as unique_ptrs so
TypoCorrectionConsumer can keep the callback around as long as needed.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@220693 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-27 18:07:29 +00:00
Fariborz Jahanian d2490044a6 Objective-C. Under a special flag, -Wcstring-format-directive,
off by default, issue a warning if %s directive is used
in formart argument of a function/method declared as
__attribute__((format(CF/NSString, ...)))
To complete rdar://18182443


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217619 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-11 19:13:23 +00:00
Fariborz Jahanian d6d59f0664 Objective-C. Under a special flag, -Wcstring-format-directive,
off by default, issue a warning if %s directive is used in
certain CF/NS formatting APIs, to assist user in deprecating
use of such %s in these APIs. rdar://18182443


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217467 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-09 23:10:54 +00:00
Craig Topper d39a2d4063 Use llvm::makeArrayRef instead of explicitly calling ArrayRef constructor and mentioning the type. This works now that we have a conversion from ArrayRef<T*> to ArrayRef<const T*>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@216824 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-30 16:55:39 +00:00
Fariborz Jahanian effffaae3b Objective-C. Allow [super initialize] in an +initialize
implementation but not anywhere else.
rdar://16628028


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@216408 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-25 21:27:38 +00:00
Fariborz Jahanian 024d9c65e9 Objective-C. Warn when @encode'ing provides an incomplete
type encoding because in certain cases, such as for vector
types, because we still haven't designed encoding for them.
rdar://9255564


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@216301 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-22 23:17:52 +00:00
Fariborz Jahanian 7d38fcd81f Objective-C. Update my previous patch to not warn if
+initialize is called on 'super' in its implementation.
rdar://16628028


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@216282 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-22 19:52:49 +00:00
Fariborz Jahanian 99ef95c3fc Objective-C. Warn if user has made explicit call
to +initilize as this results in an extra call
to this method. rdar://16628028


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@216271 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-22 16:57:26 +00:00
Fariborz Jahanian b9f1d9e841 Objective-C [qoi]. Provide fix-it hint when sending
class method to an object receiver. rdar://16263395



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@216038 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-19 23:39:17 +00:00
Fariborz Jahanian 34db924fa7 Objective-C. Do not warn if user is using property-dox syntax to name a
user provided setter name (as declared in @property attribute declaration).
rdar://18022762


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@215736 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-15 17:39:00 +00:00
Fariborz Jahanian cd21fe6e8a Objective-C. Handle case of multiple class methods
found in global pool as well. rdar://16808765


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@215603 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-13 23:38:04 +00:00
Fariborz Jahanian dc812ef2ed Objective-C. Minor refactoring of my last patch.
// rdar://16808765


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@215581 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-13 21:24:14 +00:00
Fariborz Jahanian 7cdaec7226 Objective-C. This patch is to resolve the method used in method
expression to the best method found in global method pools. 
This is wip.  // rdar://16808765


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@215577 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-13 21:07:35 +00:00
Fariborz Jahanian 7c33b6163c Objective-C [qoi]. Patch to not do Fix-It for fixing
a messaging expression except in the simple case
of a unary selector. We cannot reliably provide such a fixit due
to numerous reasons where a matching selector could not be found.
rdar://15756038


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@215480 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-12 22:16:41 +00:00
Fariborz Jahanian 6149524f3a Objective-C [qoi]. Issue warning and fixit if property-dot syntax
use mis-cased property name (which is currently accepted silently
due to the way property setters are named). rdar://17911746


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@215250 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-08 22:33:24 +00:00
Fariborz Jahanian 25fa83175c Objective-C. Minor refactoring of my previous patch.
rdar://17554063


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@215235 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-08 18:29:52 +00:00
Fariborz Jahanian 422dd7b9f7 Objective-C ARC. Use of non-retain/autorelease API
for building Objective-C array literals in ARC
mode. rdar://17554063


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@215232 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-08 17:31:14 +00:00
Fariborz Jahanian 62e6156242 Objective-C arc. Switch the Objective-C dictionary literal in ARC mode
to use non-retain/autorelease API variants of ObjC objects. wip.
rdar://17554063


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@215146 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-07 20:57:35 +00:00
Fariborz Jahanian cce419586f Objective-C ARC. More code for Objective-C's
new APIs for literals. nfc. wip. rdar://17554063


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@215043 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-06 23:40:31 +00:00
Fariborz Jahanian 8d3e43c6b1 Objective-C ARC. First patch toward generating new APIs
for Objective-C's array and dictionary literals.
rdar://17554063. This is wip.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@214983 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-06 18:13:46 +00:00
Aaron Ballman 306de08679 Replacing some more complex logic with a helper function call to ObjCMethod::getReturnTypeSourceRange. No functional changes intended.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@214511 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-01 13:20:09 +00:00
Fariborz Jahanian dd5b95a80e Obective-C. Patch to fix the incorrect ObjcMessageExpr argument source ranges,
when arguments are structures or classes. PR16392.
patch by Karlis Senko


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@214409 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-31 17:39:50 +00:00
Fariborz Jahanian 11b178d35a Objective-C. Warn if protocol used in an @protocol
expression is a forward declaration as this results
in undefined behavior. rdar://17768630


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@213968 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-25 19:45:01 +00:00
Alp Toker e9a2e9d4e3 Switch over a few uses of param_begin() to parameters()
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@212442 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-07 09:02:20 +00:00
Fariborz Jahanian 1b9b13db0c Objective-C ARC. Provide diagnostic and fix-it
when casting a retainable object to a objc_bridge_related
CF type with the suggestion of applying the method
specified in the bridging attribute to the object.
// rdar://15932435


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@211807 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-26 21:22:16 +00:00
Fariborz Jahanian a36053be37 Objective-C. When we use @selector(save:), etc. there may be more
than one method with mismatched type of same selector name. 
clang issues a warning to point this out since it may cause 
undefined behavior. There are cases though that some APIs 
don't care about user methods and such warnings are perceived as 
noise. This patch allows users to add paren delimiters around
selector name to turn off such warnings. So, @selector((save:)) will
turn off the warning. It also provides 'fixit' so user knows 
what to do. // rdar://16458579


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@211611 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-24 17:02:19 +00:00
Fariborz Jahanian 88a39adcf6 Objective-C ARC. Allow conversion of (void*) pointers to
retainable ObjC pointers without requiring a bridge-cast
in the context of pointer comparison as this is in effect 
a +0 context. // rdar://16627903


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@211243 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-18 23:52:49 +00:00
Fariborz Jahanian e15ff8e771 Objective-C. Revert my patch in r211234.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@211237 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-18 23:22:38 +00:00
Fariborz Jahanian 8e5db87d61 Objective-C ARC. Allow conversion of (void*) pointers to
retainable ObjC pointers without requiring a bridge-cast
by recognizing this as a +0 context. // rdar://16627903


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@211234 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-18 22:50:40 +00:00
Fariborz Jahanian 82a8be9ffd Objective-C. Check for integer overflow in Objective-C's
boxed expression. // rdar://16417427


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@211215 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-18 20:49:02 +00:00
Fariborz Jahanian 96c7d0173a Objective-C ARC. Do not warn about properties with both
IBOutlet and weak attributes when accessed being
unpredictably set to nil because usage of such properties
are always single threaded and its ivar cannot be set
to nil asynchronously. // rdar://15885642 


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@211132 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-17 23:35:13 +00:00
Alp Toker 7225802bf9 Hide the concept of diagnostic levels from lex, parse and sema
The compilation pipeline doesn't actually need to know about the high-level
concept of diagnostic mappings, and hiding the final computed level presents
several simplifications and other potential benefits.

The only exceptions are opportunistic checks to see whether expensive code
paths can be avoided for diagnostics that are guaranteed to be ignored at a
certain SourceLocation.

This commit formalizes that invariant by introducing and using
DiagnosticsEngine::isIgnored() in place of individual level checks throughout
lex, parse and sema.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@211005 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-15 23:30:39 +00:00
Fariborz Jahanian 1e56828b1a Objective-C. More tests for both bridging attributes and
a fix to make it work when CFStructs have no definition.
// rdar://17238954.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@210690 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-11 19:10:46 +00:00
Fariborz Jahanian ceaaaef14c Objective-C. Patch to handle bridge attribute warnings
correctly when both NSAttributedString and
NSMutableAttributedString are specified on the same
CFStruct via different typedefs. // rdar://17238954


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@210660 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-11 16:52:44 +00:00
Nikola Smiljanic f6cf7c7789 Refactoring. Remove Owned method from Sema.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@209812 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-29 14:05:12 +00:00
Nikola Smiljanic be481708fb Refactoring. Remove release and take methods from ActionResult. Rename takeAs to getAs.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@209800 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-29 10:55:11 +00:00
Craig Topper 6b8c5857eb [C++11] Use 'nullptr'. Sema edition.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@209613 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-26 06:22:03 +00:00
Fariborz Jahanian 5225cc82e1 Objective-C ARC. Add support for toll-free bridge
type ,and bridge attribute, checking with static_cast. 
// rdar://16756639


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@208474 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-10 17:40:11 +00:00
Fariborz Jahanian 53331ec34a Objective-C. Reduce false positive warnings with -Wselector by issuing warning
only when named selector is declared in TU and it is not declared in a system
header. rdar://16600230


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@208443 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-09 19:51:39 +00:00
Fariborz Jahanian 56844d5f63 Objective-C. Improve diagnosis of bridging types.
// rdar://16737117


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@207542 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-29 16:12:56 +00:00
John Thompson 9be87f8785 Initial implementation of -modules-earch-all option, for searching for symbols in non-imported modules.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@206977 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-23 12:57:01 +00:00
Fariborz Jahanian 4ab423cd70 Objective-C ARC. Under ARC, addition of 'bridge' attribute
on CF type is not sufficient and bridge casting is
still required for proper ownership semantics.
// rdar://16650445


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@206910 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-22 17:42:01 +00:00
Fariborz Jahanian 46ddd12e6b Objective-C. Patch to allow use of dot syntax on class
objects to fund root class's instance methods.
// rdar://16650575


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@206781 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-21 20:22:17 +00:00
Fariborz Jahanian 297e5869c5 Objective-C. Make multiple selector warning
an opt-in option under -Wselector-type-mismatch.
// rdar://16445728


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@204965 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-27 21:59:01 +00:00
Fariborz Jahanian 7513eb534a Objective-C. Consider blocks for designated initializer
warnings (warning or lack there of) as well since
blocks are another pattern for envoking other
designated initializers. // rdar://16323233


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@204081 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-17 21:41:40 +00:00
Aaron Ballman 4f8e7df26b [C++11] Replacing ObjCObjectPointerType iterators qual_begin() and qual_end() with iterator_range quals(). Updating all of the usages of the iterators with range-based for loops.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@204048 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-17 16:14:00 +00:00
Aaron Ballman 314ff89bfe [C++11] Replacing ObjCObjectType iterators qual_begin() and qual_end() with iterator_range quals(). Updating all of the usages of the iterators with range-based for loops.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@204047 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-17 15:55:30 +00:00
Fariborz Jahanian 258ede62c0 Objective-C. Issue diagnostics on mismatched methods when their selector is used
in an @selector expression. // rdar://15794055


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203693 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-12 18:34:01 +00:00
Craig Topper 34e9e13d3a [C++11] Add 'override' keyword to virtual methods that override their base class.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203640 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-12 04:55:44 +00:00
Benjamin Kramer 225d9cf75f Sema: When merging objc string literals, give the result a constant array type.
Also assert that we never create non-array string literals again.

PR18939.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@202147 91177308-0d34-0410-b5e6-96231b3b80d8
2014-02-25 12:26:20 +00:00
Alp Toker 37545f747c Rename getResultType() on function and method declarations to getReturnType()
A return type is the declared or deduced part of the function type specified in
the declaration.

A result type is the (potentially adjusted) type of the value of an expression
that calls the function.

Rule of thumb:

  * Declarations have return types and parameters.
  * Expressions have result types and arguments.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@200082 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-25 16:55:45 +00:00
Argyrios Kyrtzidis ee82f63db3 [objc] Refactor and improve functionality for the -Wunused-property-ivar warning.
- Remove the additions to ObjCMethodDecl & ObjCIVarDecl that were getting de/serialized and consolidate
  all functionality for the checking for this warning in Sema::DiagnoseUnusedBackingIvarInAccessor
- Don't check immediately after the method body is finished, check when the @implementation is finished.
  This is so we can see if the ivar was referenced by any other method, even if the method was defined after the accessor.
- Don't silence the warning if any method is called from the accessor silence it if the accessor delegates to another method via self.

rdar://15727325

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@198432 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-03 18:32:18 +00:00
Aaron Ballman aa81229216 Removing some more unnecessary manual quotes from attribute diagnostics.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@198391 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-03 02:07:43 +00:00
Fariborz Jahanian c0861a05e6 ObjectiveC. Remove false positive warning for missing property
backing ivar by not issuing this warning if ivar is referenced
somewhere and accessor makes method calls. // rdar://15727325


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@198367 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-02 22:42:09 +00:00
Alp Toker af9a02c0cd Support and use token kinds as diagnostic arguments
Introduce proper facilities to render token spellings using the diagnostic
formatter.

Replaces most of the hard-coded diagnostic messages related to expected tokens,
which all shared the same semantics but had to be multiply defined due to
variations in token order or quote marks.

The associated parser changes are largely mechanical but they expose
commonality in whole chunks of the parser that can now be factored away.

This commit uses C++11 typed enums along with a speculative legacy fallback
until the transition is complete.

Requires corresponding changes in LLVM r197895.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@197972 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-24 09:48:30 +00:00
Aaron Ballman 886611f0a7 Switched code from using hasAttr followed by getAttr to simply call getAttr directly.
No functional changes intended.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@197676 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-19 13:20:36 +00:00
Fariborz Jahanian 2dd9321fe2 Objective-C. After providing a fix-it for a
cstring, converted to NSString, produce the
matching AST for it. This also required some
refactoring of the previous code. // rdar://14106083


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@197605 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-18 21:04:43 +00:00
Fariborz Jahanian 7fe35ba9ec Objective-C. Make diagnostics and fix-its consistent
when diagnosing casting of a cstring literal to
NSString in default and -fobjc-arc mode. 
// rdar://14106083


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@197515 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-17 19:33:43 +00:00
Fariborz Jahanian bfa7a3ffd1 ObjectiveC. Further improvements of use
of objc_bridge_related attribute; eliminate
unnecessary diagnostics which is issued elsewhere,
fixit now produces a valid AST tree per convention.
This results in some simplification in handling of
this attribute as well. // rdar://15499111


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@197436 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-16 22:54:37 +00:00
Argyrios Kyrtzidis 3803363b4a [objc] If we don't know for sure what the designated initializers of the superclass are,
assume that a [super init..] inside a designated initializer also refers to a designated one
and do not warn.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@197202 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-13 03:48:17 +00:00
Fariborz Jahanian 1b13cb921b ObjectiveC. Provide a property-dot syntax for fixit
when selector in objc_bridge_related attribute names
a property. // rdar://15517899


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@196984 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-10 23:18:06 +00:00
Fariborz Jahanian b899a11878 Objective-C. Minor change to a diagnostic.
// rdar://15499111


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@196977 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-10 22:22:45 +00:00
Fariborz Jahanian 7d9ba1ec64 Improve on an objc_bridge_related diagnostic.
// rdar://15499111


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@196950 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-10 19:22:41 +00:00
Fariborz Jahanian ee46346a58 Objective-C. Provide fixit's for objc_bride_related
attributed CF to ObjC type conversions.
// rdar://15499111


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@196935 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-10 17:08:13 +00:00
Fariborz Jahanian 98e0aeb587 Objective-C: Improve on various diagnostics related to
use of objc_bridge_related attribute. // rdar://15499111



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@196828 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-09 22:04:26 +00:00
Fariborz Jahanian ea97886bac ObjectiveC. Continuing implementation of objc_bridge_related
attribute in sema and issuing a variety of diagnostics lazily 
for misuse of this attribute (and what to do) when converting 
from CF types to ObjectiveC types (and vice versa).
// rdar://15499111


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@196629 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-07 00:34:23 +00:00
Alp Toker 0fb7888788 Fix a tranche of comment, test and doc typos
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@196510 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-05 16:25:25 +00:00
Argyrios Kyrtzidis 925d54c10a [objc] Emit warning when the implementation of a secondary initializer calls on
super another initializer and when the implementation does not delegate to
another initializer via a call on 'self'.

A secondary initializer is an initializer method not marked as a designated
initializer within a class that has at least one initializer marked as a
designated initializer.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@196318 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-03 21:11:49 +00:00
Argyrios Kyrtzidis 2d9de48ac1 [objc] Emit warnings when the implementation of a designated initializer calls on
super an initializer that is not a designated one or any initializer on self.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@196317 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-03 21:11:43 +00:00