summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema
Commit message (Collapse)AuthorAgeFilesLines
...
* [CodeCompletion] Don't crash on member inits of templated constructors.Benjamin Kramer2015-07-091-3/+7
| | | | | | | Also fixes a crash (on invalid) member functions with a colon initializer. PR23948. llvm-svn: 241811
* Disable 32-bit SEH, againReid Kleckner2015-07-081-4/+0
| | | | | | | | Move the diagnostic back to codegen so that we can compile ATL on the self-host bot. We don't actually end up emitting code for the __try, so the diagnostic won't be hit. llvm-svn: 241761
* [modules] Fix merging support for forward-declared enums with fixed ↵Richard Smith2015-07-081-7/+14
| | | | | | underlying types. A visible declaration is enough to make the type complete, but not enough to make the definition visible. llvm-svn: 241743
* SemaDeclObjC.cpp: Escape \@ in comment lines. [-Wdocumentation]NAKAMURA Takumi2015-07-081-2/+2
| | | | llvm-svn: 241664
* Silence a -Wcast-qual warning; NFC.Aaron Ballman2015-07-071-11/+7
| | | | llvm-svn: 241581
* [libclang] When inferring nonnull use the contextual keyword for the ↵Douglas Gregor2015-07-071-0/+5
| | | | | | | | | | code-completion results, when appropriate. rdar://20742295 llvm-svn: 241560
* [libclang] Replace ObjC generic parameters when code-completing method ↵Douglas Gregor2015-07-071-1/+4
| | | | | | | | implementations. rdar://20643768 llvm-svn: 241559
* [libclang] Fix code-completion of block parameters that are marked with ↵Douglas Gregor2015-07-071-0/+5
| | | | | | | | nullability specifier. rdar://20755276 llvm-svn: 241558
* [libclang] Replace ObjC generic parameters in code-completion results.Douglas Gregor2015-07-072-40/+79
| | | | | | rdar://19369529 llvm-svn: 241557
* Implement variance for Objective-C type parameters.Douglas Gregor2015-07-071-3/+68
| | | | | | | | | | | | | | | 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
* Implement the Objective-C __kindof type qualifier.Douglas Gregor2015-07-073-33/+96
| | | | | | | | | | 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
* Warn when an intended Objective-C specialization was actually a useless ↵Douglas Gregor2015-07-071-0/+63
| | | | | | | | | | | | | | | | | | | | | | protocol qualification. Warn in cases where one has provided redundant protocol qualification that might be a typo for a specialization, e.g., NSArray<NSObject>, which is pointless (NSArray declares that it conforms to NSObject) and is likely to be a typo for NSArray<NSObject *>, i.e., an array of NSObject pointers. This warning is very narrow, only applying when the base type being qualified is parameterized, has the same number of parameters as their are protocols listed, all of the names can also refer to types (including Objective-C class types, of course), and at least one of those types is an Objective-C class (making this a typo for a missing '*'). The limitations are partly for performance reasons (we don't want to do redundant name lookup unless we really need to), and because we want the warning to apply in very limited cases to limit false positives. Part of rdar://problem/6294649. llvm-svn: 241547
* Warn when an Objective-C collection literal element is converted to an ↵Douglas Gregor2015-07-071-0/+102
| | | | | | | | | | | | incompatible type. Objective-C collection literals produce unspecialized NSArray/NSDictionary objects that can then be implicitly converted to specialized versions of these types. In such cases, check that the elements in the collection are suitable for the specialized collection. Part of rdar://problem/6294649. llvm-svn: 241546
* C++ support for Objective-C lightweight generics.Douglas Gregor2015-07-074-149/+491
| | | | | | | | | | | | | | | | | | | Teach C++'s tentative parsing to handle specializations of Objective-C class types (e.g., NSArray<NSString *>) as well as Objective-C protocol qualifiers (id<NSCopying>) by extending type-annotation tokens to handle this case. As part of this, remove Objective-C protocol qualifiers from the declaration specifiers, which never really made sense: instead, provide Sema entry points to make them part of the type annotation token. Among other things, this properly diagnoses bogus types such as "<NSCopying> id" which should have been written as "id <NSCopying>". Implements template instantiation support for, e.g., NSArray<T>* in C++. Note that parameterized classes are not templates in the C++ sense, so that cannot (for example) be used as a template argument for a template template parameter. Part of rdar://problem/6294649. llvm-svn: 241545
* Improve the Objective-C common-type computation used by the ternary operator.Douglas Gregor2015-07-071-5/+5
| | | | | | | | | | | | | | | | The Objective-C common-type computation had a few problems that required a significant rework, including: - Quadradic behavior when finding the common base type; now it's linear. - Keeping around type arguments when computing the common type between a specialized and an unspecialized type - Introducing redundant protocol qualifiers. Part of rdar://problem/6294649. Also fixes rdar://problem/19572837 by addressing a longstanding bug in ASTContext::CollectInheritedProtocols(). llvm-svn: 241544
* Substitute type arguments into uses of Objective-C interface members.Douglas Gregor2015-07-077-73/+111
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Handle Objective-C type arguments.Douglas Gregor2015-07-075-152/+678
| | | | | | | | | | | | | | | | | | | | | 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
* Parsing, semantic analysis, and AST for Objective-C type parameters.Douglas Gregor2015-07-073-14/+313
| | | | | | | | | | | | | | | | | | | | 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
* Revert "Revert 241171, 241187, 241199 (32-bit SEH)."Reid Kleckner2015-07-071-0/+5
| | | | | | | | | | | This reverts commit r241244, but restricts SEH support to Win64. This way, Chromium builds will still fall back on TUs with SEH, and Clang developers can work on this incrementally upstream while patching this small predicate locally. It'll also make it easier to review small fixes. llvm-svn: 241533
* Refactor to avoid long if-condition.Richard Smith2015-07-061-8/+23
| | | | llvm-svn: 241518
* [Sema] Warn when shifting a negative value.Davide Italiano2015-07-061-2/+12
| | | | | | | | | | | | | | | Example: % ./clang -Wshift-negative-value emit.c emit.c:3:14: warning: shifting a negative signed value is undefined [-Wshift-negative-value] int a = -1 << 3; ~~ ^ 1 warning generated. PR: 24026 Differential Revision: http://reviews.llvm.org/D10938 Reviewed by: rsmith llvm-svn: 241478
* PR24030, PR24033: Consistently check whether a new declaration conflicts withRichard Smith2015-07-062-27/+102
| | | | | | | | | | an existing using shadow declaration if they define entities of the same kind in different namespaces. We'd previously check this consistently if the using-declaration came after the other declaration, but not if it came before. llvm-svn: 241428
* DR1909: Diagnose all invalid cases of a class member sharing its name with ↵Richard Smith2015-07-062-6/+21
| | | | | | the class. llvm-svn: 241425
* When we see something that looks like a constructor with a return type, only ↵Richard Smith2015-07-061-5/+6
| | | | | | issue one error, not two. llvm-svn: 241424
* Switch users of the 'for (StmtRange range = stmt->children(); range; ↵Benjamin Kramer2015-07-026-27/+24
| | | | | | | | | ++range)‘ pattern to range for loops. The pattern was born out of the lack of range-based for loops in C++98 and is somewhat obscure. No functionality change intended. llvm-svn: 241300
* [Sema] Range-loopify SemaTemplateInstantiateDecl.cpp. NFC.Davide Italiano2015-07-021-8/+6
| | | | llvm-svn: 241291
* [OPENMP 4.0] Initial support for 'omp cancel' construct.Alexey Bataev2015-07-022-3/+67
| | | | | | Implemented parsing/sema analysis + (de)serialization. llvm-svn: 241253
* Revert 241171, 241187, 241199 (32-bit SEH).Nico Weber2015-07-021-5/+0
| | | | | | | It still doesn't produce quite the right code, test binaries built with this enabled fail some tests. llvm-svn: 241244
* Parse 'technical term' format specifier.Ted Kremenek2015-07-021-1/+46
| | | | | | | | | | | | | | | | | | | | | | | Objective-C format strings now support modifier flags that can be attached to a '@' conversion. Currently the only one supported, as of iOS 9 and OS X 10.11, is the new "technical term", denoted by the flag "tt", for example: %[tt]@ instead of just: %@ The 'tt' stands for "technical term", which is used by the string-localization facilities on Darwin to add the appropriate spacing or quotation depending the language locale. Implements <rdar://problem/20374720>. llvm-svn: 241243
* [OPENMP] Introduced type trait "__builtin_omp_required_simd_align" for ↵Alexey Bataev2015-07-021-1/+4
| | | | | | | | | default simd alignment. Adds type trait "__builtin_omp_required_simd_align" after discussions here http://reviews.llvm.org/D9894 Differential Revision: http://reviews.llvm.org/D10597 llvm-svn: 241237
* [Sema] Range-loopify InititializationSequence destructor. NFC intended.Davide Italiano2015-07-011-4/+2
| | | | llvm-svn: 241195
* [SEH] Add 32-bit lowering for SEH __tryReid Kleckner2015-07-011-0/+5
| | | | | | | | | | | | | | | | | | | This re-lands r236052 and adds support for __exception_code(). In 32-bit SEH, the exception code is not available in eax. It is only available in the filter function, and now we arrange to load it and store it into an escaped variable in the parent frame. As a consequence, we have to disable the "catch i8* null" optimization on 32-bit and always generate a filter function. We can re-enable the optimization if we detect an __except block that doesn't use the exception code, but this probably isn't worth optimizing. Reviewers: majnemer Differential Revision: http://reviews.llvm.org/D10852 llvm-svn: 241171
* [modules] Don't require the 'inline' specifier when merging an inline function;Richard Smith2015-07-011-1/+1
| | | | | | any source of the inline nature is sufficient. llvm-svn: 241146
* [OPENMP 4.0] Initial support for 'omp cancellation point' construct.Alexey Bataev2015-07-012-16/+122
| | | | | | Add parsing and sema analysis for 'omp cancellation point' directive. llvm-svn: 241145
* [Sema] Don't crash when deduction fails for decltype(auto)David Majnemer2015-07-011-0/+2
| | | | | | | | | We didn't check the return result of BuildDecltypeType, resulting in us crashing when we tried to grab the canonical version of the type. This fixes PR23995. llvm-svn: 241131
* [CONCEPTS] Parsing of concept keywordHubert Tong2015-06-301-0/+12
| | | | | | | | | | | | | | | | | | Summary: This change adds parsing for the concept keyword in a declaration and tracks the location. Diagnostic testing added for invalid use of concept keyword. Reviewers: faisalv, fraggamuffin, rsmith, hubert.reinterpretcast Reviewed By: rsmith, hubert.reinterpretcast Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D10528 Patch by Nathan Wilson! llvm-svn: 241060
* Rework parsing of pure-specifiers. Perform the grammar matching andRichard Smith2015-06-302-30/+13
| | | | | | disambiguation in the parser rather than trying to do it in Sema. llvm-svn: 241032
* PR23942: a pure-specifier's integer literal must be spelled '0'Richard Smith2015-06-291-3/+18
| | | | llvm-svn: 241019
* Add support for the x86 builtin __builtin_cpu_supports.Eric Christopher2015-06-291-0/+22
| | | | | | | | | | | | | | | | | | | | This matches the implementation of the gcc support for the same feature, including checking the values set up by libgcc at runtime. The structure looks like this: unsigned int __cpu_vendor; unsigned int __cpu_type; unsigned int __cpu_subtype; unsigned int __cpu_features[1]; with a set of enums to match various fields that are field out after parsing the output of the cpuid instruction. This also adds a set of errors checking for valid input (and cpu). compiler-rt support for this and the other builtins in this family (__builtin_cpu_init and __builtin_cpu_is) are forthcoming. llvm-svn: 240994
* Instantiation of local class members.Serge Pavlov2015-06-292-6/+27
| | | | | | | | | | | | If a function containing a local class is instantiated, instantiate all of local class member, including default arguments and exception specifications. This change fixes PR21332 and thus implements DR1484. Differential Revision: http://reviews.llvm.org/D9990 llvm-svn: 240974
* [Sema] Unions cannot have virtual functions.Davide Italiano2015-06-271-0/+5
| | | | | | | | PR: PR23931 Differential Revision: http://reviews.llvm.org/D10752 Reviewed by: rsmith llvm-svn: 240889
* [ObjC] Add NSValue support for objc_boxed_expressionsAlex Denisov2015-06-263-9/+154
| | | | | | | | | | | | | 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)]; llvm-svn: 240761
* Fix crash-on-invalid bug in template instantiation.Manuel Klimek2015-06-261-27/+0
| | | | | | | | Get rid of code-path that (according to Richard Smith) is not needed but leads to a crasher bug when assuming a template has been fully instantiated and thus has a definition. llvm-svn: 240752
* [Sema] Maintain ellipsis location when transforming lambda capturesMeador Inge2015-06-261-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch fixes a crash caused by the following case: template<typename T> auto f(T x) { auto g = [](auto ... args) { auto h = [args...]() -> int { return 0; }; return h; }; return g; } auto x = f(0)(); When the templated function 'f' is instantiated and the inner-most lambda is transformed the ellipsis location on the captured variable is lost. Then the lambda returned by 'f' is instantiated and the tree transformer chokes on the invalid ellipsis location. The problem is fixed by making a minor change to properly track the ellipsis location. This fixes PR23716. Differential Revision: http://reviews.llvm.org/D10590 llvm-svn: 240740
* Fix a typo correction crash when resolving ambiguous corrections.Kaelyn Takata2015-06-251-0/+6
| | | | | | | | | | | In certain cases, the tree transform would introduce new TypoExprs while trying one of the corrections, invalidating the unique_ptr in the state reference, and also causing a TypoExpr to exist that will never be corrected since it doesn't exist in the final corrected expression. The simple solution to both problems is to temporarily disable typo correction while handling potentially ambiguous typo corrections. llvm-svn: 240734
* [Parse] Allow 'constexpr' in condition declarationsMeador Inge2015-06-251-6/+7
| | | | | | | | | | | | | | | | | This patch implements the functionality specified by DR948. The changes are two fold. First, the parser was modified to allow 'constexpr's to appear in condition declarations (which was a hard error before). Second, Sema was modified to cleanup maybe odr-used declarations by way of a call to 'ActOnFinishFullExpr'. As 'constexpr's were not allowed in condition declarations before the cleanup wasn't necessary (such declarations were always odr-used). This fixes PR22491. Differential Revision: http://reviews.llvm.org/D8978 llvm-svn: 240707
* Fix #pragma redefine_extname when there is a local variable of the same ↵Aaron Ballman2015-06-251-2/+17
| | | | | | | | name. The local should not be renamed, only the externally-available declaration should be. Patch by Andrey Bokhanko! llvm-svn: 240653
* Consolidate and unify initializer list deductionHubert Tong2015-06-251-33/+49
| | | | | | | | | | | | | | | | | | | | | | | Summary: This patch reduces duplication in the template argument deduction code for handling deduction from initializer lists in a function call. This extends the fix for PR12119 to also apply to the case where the corresponding parameter is a trailing parameter pack. Test Plan: A test for deduction from nested initializer lists where the corresponding parameter is a trailing parameter pack is added in `clang/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp`. Reviewers: fraggamuffin, rsmith Reviewed By: rsmith Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D10681 llvm-svn: 240612
* Replace __double_underscored type nullability qualifiers with ↵Douglas Gregor2015-06-246-58/+62
| | | | | | | | | | | | | | | | _Uppercase_underscored Addresses a conflict with glibc's __nonnull macro by renaming the type nullability qualifiers as follows: __nonnull -> _Nonnull __nullable -> _Nullable __null_unspecified -> _Null_unspecified This is the major part of rdar://problem/21530726, but does not yet provide the Darwin-specific behavior for the old names. llvm-svn: 240596
* Make the typo resolution in r240441 apply to all function calls.Kaelyn Takata2015-06-231-11/+12
| | | | | | | | | | Regular function calls (such as to cabs()) run into the same problem with handling dependent exprs, not just builtins with custom type checking. Fixes PR23775. llvm-svn: 240443
OpenPOWER on IntegriCloud