Commit Graph

318 Commits

Author SHA1 Message Date
Manman Ren 5b786407d0 Class Property: class property and instance property can have the same name.
Add "enum ObjCPropertyQueryKind" to a few APIs that used to only take the name
of the property: ObjCPropertyDecl::findPropertyDecl,
ObjCContainerDecl::FindPropertyDeclaration,
ObjCInterfaceDecl::FindPropertyVisibleInPrimaryClass,
ObjCImplDecl::FindPropertyImplDecl, and Sema::ActOnPropertyImplDecl.

ObjCPropertyQueryKind currently has 3 values:
OBJC_PR_query_unknown, OBJC_PR_query_instance, OBJC_PR_query_class

This extra parameter specifies that we are looking for an instance property with
the given name, or a class property with the given name, or any property with
the given name (if both exist, the instance property will be returned).

rdar://23891898

llvm-svn: 259070
2016-01-28 18:49:28 +00:00
Xiuli Pan 9c14e28211 [OpenCL] Pipe type support
Summary:
Support for OpenCL 2.0 pipe type.
This is a bug-fix version for bader's patch reviews.llvm.org/D14441


Reviewers: pekka.jaaskelainen, Anastasia

Subscribers: bader, Anastasia, cfe-commits

Differential Revision: http://reviews.llvm.org/D15603

llvm-svn: 257254
2016-01-09 12:53:17 +00:00
David Majnemer 902f8c6fcb ArrayRef-ize TemplateParameterList. NFC
llvm-svn: 256463
2015-12-27 07:16:27 +00:00
Craig Topper e6337e1ebf Revert r256399 "[Sema] ArrayRef-ize ActOnBaseSpecifiers. NFC"
It broke lldb build.

llvm-svn: 256403
2015-12-25 00:36:02 +00:00
Craig Topper 6550a4b17e [Sema] ArrayRef-ize ActOnBaseSpecifiers. NFC
llvm-svn: 256399
2015-12-24 23:58:20 +00:00
Richard Smith e301ba2b48 Add support for GCC's '__auto_type' extension, per the GCC manual:
https://gcc.gnu.org/onlinedocs/gcc/Typeof.html

Differences from the GCC extension:
 * __auto_type is also permitted in C++ (but only in places where
   it could appear in C), allowing its use in headers that might
   be shared across C and C++, or used from C++98
 * __auto_type can be combined with a declarator, as with C++ auto
   (for instance, "__auto_type *p")
 * multiple variables can be declared in a single __auto_type
   declaration, with the C++ semantics (the deduced type must be
   the same in each case)

This patch also adds a missing restriction on applying typeof to
a bit-field, which GCC has historically rejected in C (due to
lack of clarity as to whether the operand should be promoted).
The same restriction also applies to __auto_type in C (in both
GCC and Clang).

This also fixes PR25449.

Patch by Nicholas Allegra!

llvm-svn: 252690
2015-11-11 02:02:15 +00:00
Richard Smith 9f690bd80b [coroutines] Creation of promise object, lookup of operator co_await, building
of await_* calls, and AST representation for same.

llvm-svn: 251387
2015-10-27 06:02:45 +00:00
Angel Garcia Gomez 637d1e6694 Roll-back r250822.
Summary: It breaks the build for the ASTMatchers

Subscribers: klimek, cfe-commits

Differential Revision: http://reviews.llvm.org/D13893

llvm-svn: 250827
2015-10-20 13:23:58 +00:00
Angel Garcia Gomez b5250d3448 Apply modernize-use-default to clang.
Summary: Replace empty bodies of default constructors and destructors with '= default'.

Reviewers: bkramer, klimek

Subscribers: klimek, alexfh, cfe-commits

Differential Revision: http://reviews.llvm.org/D13890

llvm-svn: 250822
2015-10-20 12:52:55 +00:00
Craig Topper c005cc06cd Use llvm::makeArrayRef. NFC.
llvm-svn: 248678
2015-09-27 03:44:08 +00:00
Benjamin Kramer cce6347be5 [AST] ArrayRefize template argument packs. No functionality change intended.
llvm-svn: 244026
2015-08-05 09:40:22 +00:00
Douglas Gregor ab7f0b342f The AST importer had a bug where it would enter into an infinite recursion
when importing type parameter lists.  The reason is that type parameters
have their DeclContexts set to the interface that is parameterized with those
types, and the importer would follow that loop and blow the stack out.

I've changed the way this works so that the type parameters are only imported
after the interface that contains them has been registered via the Imported()
function.

This is tested by LLDB.

<rdar://problem/20315663>

llvm-svn: 241556
2015-07-07 06:20:12 +00:00
Douglas Gregor 1ac1b63c9c Implement variance for Objective-C type parameters.
Introduce co- and contra-variance for Objective-C type parameters,
which allows us to express that (for example) an NSArray is covariant
in its type parameter. This means that NSArray<NSMutableString *> * is
a subtype of NSArray<NSString *> *, which is expected of the immutable
Foundation collections.

Type parameters can be annotated with __covariant or __contravariant
to make them co- or contra-variant, respectively. This feature can be
detected by __has_feature(objc_generics_variance). Implements
rdar://problem/20217490.

llvm-svn: 241549
2015-07-07 03:58:54 +00:00
Douglas Gregor ab209d83be 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.

llvm-svn: 241548
2015-07-07 03:58:42 +00:00
Douglas Gregor e83b95641f 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 *).

llvm-svn: 241543
2015-07-07 03:57:53 +00:00
Douglas Gregor e9d95f1ecc 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.

llvm-svn: 241542
2015-07-07 03:57:35 +00:00
Douglas Gregor 85f3f9513d 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.

llvm-svn: 241541
2015-07-07 03:57:15 +00:00
Alexander Kornienko ab9db51042 Revert r240270 ("Fixed/added namespace ending comments using clang-tidy").
llvm-svn: 240353
2015-06-22 23:07:51 +00:00
Alexander Kornienko 3d9d929e42 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.

llvm-svn: 240270
2015-06-22 09:47:44 +00:00
Douglas Gregor 813a066f16 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.

llvm-svn: 240154
2015-06-19 18:14:38 +00:00
Sean Callanan 25d34af88a Use a more reliable method to determine whether
a FileID corresponds to a real file or to a
memory buffer.  The old method didn't work when
Clang was built Release, which meant it wasn't
a very good method at all.

llvm-svn: 236188
2015-04-30 00:44:21 +00:00
Sean Callanan 59721b3d3f Implemented ASTImporter support for Stmts and fixed
some bugs in the ASTImporter that this exposed:

- When importing functions, the body (if any) was
  previously ignored.  This patch ensures that the
  body is imported also.

- When a function-local Decl is imported, the first
  thing the ASTImporter does is import its context
  (via ImportDeclParts()).  This can trigger 
  importing the Decl again as part of the body of
  the function (but only once, since the function's
  Decl has been added to ImportedDecls).  This patch
  fixes that problem by extending ImportDeclParts()
  to return the imported Decl if it was imported as
  part of importing its context, and the patch adds
  ASTImporter::GetAlreadyImportedOrNull() to support
  this query.  All callers of ImportDeclParts return
  the imported version of the Decl if ImportDeclParts()
  returns it.

- When creating functions, InnerLocStart of the source
  function was re-used without importing.  This is a
  straight up bug, and this patch makes ASTImporter
  import the InnerLocStart and use the imported version.

- When importing FileIDs, the ASTImporter previously
  always tried to re-load the file for the corresponding
  CacheEntry from disk.  This doesn't work if the 
  CacheEntry corresponds to a named memory buffer.  This
  patch changes the code so that if the UniqueID for the
  cache entry is invalid (i.e., it is not a disk file)
  the whole entry is treated as if it were invalid, which
  forces an in-memory copy of the buffer.

Also added test cases, using the new support committed in
236011.

llvm-svn: 236012
2015-04-28 18:41:46 +00:00
Sean Callanan 72fe0852fd Added support for attributed types to the ASTImporter.
<rdar://problem/20403544>

llvm-svn: 233985
2015-04-02 23:50:08 +00:00
Alexey Bataev 19acc3d351 Rename RefersToCapturedVariable to RefersToEnclosingVariableOrCapture, NFC
llvm-svn: 225624
2015-01-12 10:17:46 +00:00
Alexey Bataev 07649fb7c5 Renamed RefersToEnclosingLocal bitfield to RefersToCapturedVariable.
Bitfield RefersToEnclosingLocal of Stmt::DeclRefExprBitfields renamed to RefersToCapturedVariable to reflect latest changes introduced in commit 224323. Also renamed method Expr::refersToEnclosingLocal() to Expr::refersToCapturedVariable() and comments for constant arguments.
No functional changes.

llvm-svn: 224329
2014-12-16 08:01:48 +00:00
Sean Callanan b12a855ba8 Fixed an 80-column violation.
Thanks to Nico Weber for spotting this.

llvm-svn: 223966
2014-12-10 21:22:20 +00:00
Sean Callanan 49475327ff Fixed the AST importer ot use redeclaration contexts properly.
To ensure that we don't import duplicates, the ASTImporter often
checks the DeclContext for a Decl before importing it to see if
a Decl with the same name is already present.  

This is problematic if the Decl is inside a transparent context
like an extern "C" block.  Lookup isn't allowed on such contexts,
and in fact they assert() if you do that.  So instead we look at
the redeclaration context -- the containing context that can be
used safely for these kinds of checks -- instead.

llvm-svn: 223912
2014-12-10 03:09:41 +00:00
Sean Callanan 238d897b07 Made the ASTImporter resilient if it can't import
SourceLocations.  LLDB rarely has the same files
mapped into the target AST context as the source
AST context, so the ASTImporter shouldn't expect
to see those files there.

This started to become a problem when importing
entities from modules -- these have proper source
locations, in contrast to all the ASTs LLDB
creates which have empty ones.

llvm-svn: 223900
2014-12-10 01:26:39 +00:00
Sean Callanan 0aae04175b Updated the AST importer to support importing
LinkageSpecDecls.  This is relevant when LLDB
wants to import Decls from non-C++ modules,
since many declarations are in extern "C"
blocks.

llvm-svn: 223860
2014-12-10 00:00:37 +00:00
David Blaikie 3c7dd6be20 Correct importing of the type of a TemplateArgument
It's not clear how this would be tested - I imagine we should have an
ASTImporter test that RAVs the new AST and checks that all the elements
in it are from this ASTContext and not the foreign one... but I know
little about the ASTImporter and how/where that testing might be done.

(post-commit review feedback from Richard Smith on r219900)

llvm-svn: 220411
2014-10-22 19:54:16 +00:00
David Blaikie 952a9b1743 Rename TemplateArgument::getTypeForDecl to getParamTypeForDecl for clarity
Code review feedback from Richard Smith on r219900.

llvm-svn: 220060
2014-10-17 18:00:12 +00:00
David Blaikie 0f62c8d8f8 PR21246: DebugInfo: Emit the appropriate type (cv qualifiers, reference-ness, etc) for non-type template parameters
Plumb through the full QualType of the TemplateArgument::Declaration, as
it's insufficient to only know whether the type is a reference or
pointer (that was necessary for mangling, but insufficient for debug
info). This shouldn't increase the size of TemplateArgument as
TemplateArgument::Integer is still longer by another 32 bits.

Several bits of code were testing that the reference-ness of the
parameters matched, but this seemed to be insufficient (various other
features of the type could've mismatched and wouldn't've been caught)
and unnecessary, at least insofar as removing those tests didn't cause
anything to fail.

(Richard - perchaps you can hypothesize why any of these checks might
need to test reference-ness of the parameters (& explain why
reference-ness is part of the mangling - I would've figured that for the
reference-ness to be different, a prior template argument would have to
be different). I'd be happy to add them in/beef them up and add test
cases if there's a reason for them)

llvm-svn: 219900
2014-10-16 04:21:25 +00:00
Aaron Ballman 260995b86b Adding attributes to the IndirectFieldDecl that we generate for anonymous struct/union fields. This fixes PR20930.
llvm-svn: 219807
2014-10-15 16:58:18 +00:00
Nikola Smiljanic 67860249e0 -ms-extensions: Implement __super scope specifier (PR13236).
We build a NestedNameSpecifier that records the CXXRecordDecl in which
__super appeared. Name lookup is performed in all base classes of the
recorded CXXRecordDecl. Use of __super is allowed only inside class and
member function scope.

llvm-svn: 218484
2014-09-26 00:28:20 +00:00
David Blaikie 50a5f97e82 unique_ptrify SourceManager::createFileID
llvm-svn: 216715
2014-08-29 07:59:55 +00:00
Rafael Espindola d87f8d76e0 Update for LLVM api change.
llvm-svn: 216585
2014-08-27 20:03:29 +00:00
Richard Smith 8acb4280c5 Factor out exception specification information from
FunctionProtoType::ExtProtoInfo. Most of the users of these fields don't care
about the other ExtProtoInfo bits and just want to talk about the exception
specification.

llvm-svn: 214450
2014-07-31 21:57:55 +00:00
Craig Topper 7e0daca110 Convert some function arguments to use ArrayRef.
llvm-svn: 211764
2014-06-26 04:58:53 +00:00
Alp Toker 6ac2cd01d2 Rename SourceManager::createFileIDForMemBuffer()
It makes more sense to just overload createFileID().

Gardening only.

llvm-svn: 209002
2014-05-16 17:23:01 +00:00
Craig Topper 36250ad632 [C++11] Use 'nullptr'. AST edition.
llvm-svn: 208517
2014-05-12 05:36:57 +00:00
Craig Topper dcfc60ff41 Fix up indentation and fix an 80 column violation.
llvm-svn: 208164
2014-05-07 06:57:44 +00:00
Aaron Ballman 1683f7baf6 [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.
llvm-svn: 204047
2014-03-17 15:55:30 +00:00
Aaron Ballman b088fbee3f [C++11] Replacing FunctionProtoType iterators exception_begin() and exception_end() with iterator_range exceptions(). Updating all of the usages of the iterators with range-based for loops.
llvm-svn: 204046
2014-03-17 15:38:09 +00:00
Aaron Ballman 40bd0aaf68 [C++11] Replacing FunctionProtoType iterators param_type_begin() and param_type_end() with iterator_range param_types(). Updating all of the usages of the iterators with range-based for loops.
llvm-svn: 204045
2014-03-17 15:23:01 +00:00
Aaron Ballman 15063e19c6 [C++11] Replacing ObjCInterfaceDecl iterators known_categories_begin() and known_categories_end() with iterator_range known_categories(). Updating all of the usages of the iterators with range-based for loops.
llvm-svn: 203854
2014-03-13 21:35:02 +00:00
Aaron Ballman 574705ed7f [C++11] Replacing CXXRecordDecl iterators bases_begin() and bases_end() with iterator_range bases(). Updating all of the usages of the iterators with range-based for loops.
llvm-svn: 203803
2014-03-13 15:41:46 +00:00
Aaron Ballman 629afaefe0 [C++11] Replacing DeclBase iterators decls_begin() and decls_end() with iterator_range decls(). The same is true for the noload versions of these APIs. Updating all of the usages of the iterators with range-based for loops.
llvm-svn: 203278
2014-03-07 19:56:05 +00:00
Aaron Ballman 29c9460d3e Renaming the chains() ranged iterator to chain() per suggestion by Richard Smith.
llvm-svn: 203262
2014-03-07 18:36:15 +00:00
Aaron Ballman 1391608234 [C++11] Replacing IndirectFieldDecl iterators chain_begin() and chain_end() with iterator_range chains(). Updating all of the usages of the iterators with range-based for loops.
llvm-svn: 203261
2014-03-07 18:11:58 +00:00
Aaron Ballman 43b68bebe7 [C++11] Replacing ObjCMethodDecl iterators param_begin() and param_end() with iterator_range params(). Updating all of the usages of the iterators with range-based for loops.
llvm-svn: 203255
2014-03-07 17:50:17 +00:00