summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema
Commit message (Collapse)AuthorAgeFilesLines
...
* [Sema] Fix bug in TypeLocBuilder::pushImplAkira Hatanaka2016-02-181-4/+32
| | | | | | | | | | | | | | The code in TypeLocBuilder::pushImpl wasn't correctly handling the case where an element that has an 8-byte alignment was being pushed. I plan to follow up with a patch to remove redundancies and simplify the function. rdar://problem/23838912 Differential Revision: http://reviews.llvm.org/D16843 llvm-svn: 261260
* [Parse] Code complete expressions in bracket declarators.Benjamin Kramer2016-02-181-0/+4
| | | | | | | | | | Currently we return no results when completing inside of the brackets in a 'char foo[]' declaration. Let the generic expression completion code handle it instead. We could get fancier here (e.g. filter non-constant expressions in contexts where VLAs are not allowed), but it's a strict improvement over the existing version. llvm-svn: 261217
* Sema: provide an extension warning for enable_ifSaleem Abdulrasool2016-02-181-0/+2
| | | | | | | Clang implements an enable_if attribute as an extension. Hook up `-Wpedantic` to issue an extension usage warning when __enable_if__ is used. llvm-svn: 261192
* Add 'nopartial' qualifier for availability attributes.Manman Ren2016-02-174-8/+46
| | | | | | | | | | | | | | | | | | | | | | An optional nopartial can be placed after the platform name. int bar() __attribute__((availability(macosx,nopartial,introduced=10.12)) When deploying back to a platform version prior to when the declaration was introduced, with 'nopartial', Clang emits an error specifying that the function is not introduced yet; without 'nopartial', the behavior stays the same: the declaration is `weakly linked`. A member is added to the end of AttributeList to save the location of the 'nopartial' keyword. A bool member is added to AvailabilityAttr. The diagnostics for 'nopartial' not-yet-introduced is handled in the same way as we handle unavailable cases. Reviewed by Doug Gregor and Jordan Rose. rdar://23791325 llvm-svn: 261163
* [modules] Cache 'acceptable decl' lookups for namespaces. In projects withRichard Smith2016-02-172-0/+24
| | | | | | | | | | | | | | | | thousands of modules, each of which declares the same namespace, linearly scanning the redecl chain looking for a visible declaration (once for each leaf module, for each use) performs very poorly. Namespace visibility can only decrease when we leave a module during a module build step, and we never care *which* visible declaration of a namespace we find, so we can cache this very effectively. This results in a 35x speedup on one of our internal build steps (2m -> 3.5s), but is hard to unit test because it requires a very large number of modules. Ideas for a test appreciated! No functionality change intended other than the speedup. llvm-svn: 261161
* Correct more typos in conditional expressionsDavid Majnemer2016-02-171-1/+16
| | | | | | | We didn't correctly handle some edge cases, causing us to bail out before correcting all the typos. llvm-svn: 261109
* [OPENMP 4.5] Codegen support for data members in 'firstprivate' clause.Alexey Bataev2016-02-171-2/+12
| | | | | | Added codegen for captured data members in non-static member functions. llvm-svn: 261089
* [OpenCL] Added half type literal with suffix h.Anastasia Stulova2016-02-171-1/+8
| | | | | | | | | | | | | OpenCL Extension v1.2 s9.5 allows half precision floating point type literals with suffices h or H when cl_khr_fp16 is enabled. Example: half x = 1.0h; Patch by Liu Yaxun (Sam)! Differential Revision: http://reviews.llvm.org/D16865 llvm-svn: 261084
* [OPENMP] Fix handling loop-based directives with arrays.Alexey Bataev2016-02-171-68/+106
| | | | | | | Patch fixes possible problems with correct handling arrays as expressions in initialization, conditions etc in loop-based constructs. llvm-svn: 261080
* Improve diagnostics for ill-formed literal operator declarations.Richard Smith2016-02-171-86/+144
| | | | | | Patch by Erik Pilkington! llvm-svn: 261034
* [typo-correction] Apply name specifier corrections when forming a NNSReid Kleckner2016-02-161-0/+4
| | | | | | | | Previously we would leave behind the old name specifier prefix, which creates an invalid AST. Other callers of CorrectTypo update their CXXScopeSpec objects with the correction specifier if one is present. llvm-svn: 260993
* [OPENMP] Allow to use compound assignment operators.Alexey Bataev2016-02-161-10/+37
| | | | | | Loop-based directives allow to use iterators as loop counters. Iterators are allowed to define their own operators. This patch allows to use compound assignment operators for iterators. llvm-svn: 260957
* [OPENMP] Improved handling of pseudo-captured expressions in OpenMP.Alexey Bataev2016-02-161-20/+41
| | | | | | | | Expressions inside 'schedule'|'dist_schedule' clause must be captured in combined directives to avoid possible crash during codegen. Patch improves handling of such constructs llvm-svn: 260954
* Sema: prevent assertion on stack return checkingSaleem Abdulrasool2016-02-151-2/+4
| | | | | | | | | | | | | | In the case that the array indexing itself is within a type dependent context, bail out of the evaluation. We would previously try to symbolically evaluate the expression which would then try to evaluate a non-address expression as an address, triggering an assertion in Asserts builds. We only need to consider the array subscript expression itself as in the case that the base itself being type dependent is handled appropriately in EvalAddr. Resolves PR26599. llvm-svn: 260867
* Sema: constify EvalAddr, EvalValSaleem Abdulrasool2016-02-151-139/+146
| | | | | | | Propagate const throughout these methods as they are non-mutating analyzers of state. NFC. llvm-svn: 260864
* Fix a leak in the generated code for attributes with strings.Benjamin Kramer2016-02-131-3/+3
| | | | | | | | Storing std::strings in attributes simply doesn't work, we never call the destructor. Use an array of StringRefs instead of std::strings and copy the data into memory taken from the ASTContext. llvm-svn: 260831
* Don't copy a DenseMap just to do lookup in it.Benjamin Kramer2016-02-131-6/+1
| | | | | | | Also remove the now unused isPodLike specialization. DenseMap only uses it for copies. llvm-svn: 260822
* [Sema] More changes to fix Objective-C fallout from r249995.Bob Wilson2016-02-132-33/+51
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a follow-up to PR26085. That was fixed in r257710 but the testcase there was incomplete. There is a related issue where the overload resolution for Objective-C incorrectly picks a method that is not valid without a bridge cast. The call to Sema::CheckSingleAssignmentConstraints that was added to SemaOverload.cpp's IsStandardConversion() function does not catch that case and reports that the method is Compatible even when it is not. The root cause here is that various Objective-C-related functions in Sema do not consistently return a value to indicate whether there was an error. This was fine in the past because they would report diagnostics when needed, but r257710 changed them to suppress reporting diagnostics when checking during overload resolution. This patch adds a new ACR_error result to the ARCConversionResult enum and updates Sema::CheckObjCARCConversion to return that value when there is an error. Most of the calls to that function do not check the return value, so adding this new result does not affect them. The one exception is in SemaCast.cpp where it specifically checks for ACR_unbridged, so that is also OK. The call in Sema::CheckSingleAssignmentConstraints can then check for an ACR_okay result and identify assignments as Incompatible. To preserve the existing behavior, it only changes the return value to Incompatible when the new Diagnose argument (from r257710) is false. Similarly, the CheckObjCBridgeRelatedConversions and ConversionToObjCStringLiteralCheck need to identify when an assignment is Incompatible. Those functions already return appropriate values but they need some fixes related to the new Diagnose argument. llvm-svn: 260787
* Make -Wnull-conversion more useful.Richard Trieu2016-02-131-7/+14
| | | | | | | | | | When a null constant is used in a macro, walk through the macro stack to determine where the null constant is written and where the context is located. Only warn if both locations are within the same macro expansion. This helps function-like macros which involve pointers be treated as if they were functions. llvm-svn: 260776
* Fix remaining Clang-tidy readability-redundant-control-flow warnings; other ↵Eugene Zelenko2016-02-127-177/+92
| | | | | | | | minor fixes. Differential revision: http://reviews.llvm.org/D17218 llvm-svn: 260757
* [CUDA] Tweak attribute-based overload resolution to match nvcc behavior.Artem Belevich2016-02-122-43/+72
| | | | | | | | | | | | | | | | | | | | | | | | | | This is an artefact of split-mode CUDA compilation that we need to mimic. HD functions are sometimes allowed to call H or D functions. Due to split compilation mode device-side compilation will not see host-only function and thus they will not be considered at all. For clang both H and D variants will become function overloads visible to compiler. Normally target attribute is considered only if C++ rules can not determine which function is better. However in this case we need to ignore functions that would not be present during current compilation phase before we apply normal overload resolution rules. Changes: * introduced another level of call preference to better describe possible call combinations. * removed WrongSide functions from consideration if the set contains SameSide function. * disabled H->D, D->H and G->H calls. These combinations are not allowed by CUDA and we were reluctantly allowing them to work around device-side calls to math functions in std namespace. We no longer need it after r258880. Differential Revision: http://reviews.llvm.org/D16870 llvm-svn: 260697
* [OPENMP] Rename OMPCapturedFieldDecl to OMPCapturedExprDecl, NFC.Alexey Bataev2016-02-113-43/+40
| | | | | | | | OMPCapturedExprDecl allows caopturing not only of fielddecls, but also other expressions. It also allows to simplify codegen for several clauses. llvm-svn: 260492
* Silence some MSVC false positive warnings about integer zexts and falling ↵Reid Kleckner2016-02-101-1/+1
| | | | | | off the end of a covered switch llvm-svn: 260411
* [OPENMP 4.5] Initial support for data members in 'firstprivate' clause.Alexey Bataev2016-02-101-76/+73
| | | | | | | OpenMP 4.5 allows privatization of non-static data members of current class in non-static member functions. llvm-svn: 260374
* Fix assertion "Chunk.Kind == DeclaratorChunk::Function" with attributed type.Denis Zobnin2016-02-101-0/+7
| | | | | | | | | | This patch is to upgrade FunctionTypeUnwrapper for correct processing of AttributedType. Fixes PR25786. Patch by Alexander Makarov. Differential Revision: http://reviews.llvm.org/D15373 llvm-svn: 260373
* Fix PR26543: add a check for definition in CXXRecordDecl.Alexey Bataev2016-02-101-1/+2
| | | | llvm-svn: 260370
* [Sema] Issue a warning for integer overflow in nested struct initializerAkira Hatanaka2016-02-101-6/+14
| | | | | | | | | | | | | | | | | | | | | | | r257357 fixed clang to warn on integer overflow in struct initializers. However, it didn't warn when a struct had a nested initializer. This commit makes changes in Sema::CheckForIntOverflow to handle nested initializers. For example: struct s { struct t { unsigned x; } t; } s = { { .x = 4 * 1024 * 1024 * 1024 } }; rdar://problem/23526454 llvm-svn: 260360
* Revert "Avoid forcing emission of delayed dllexported classes on template ↵Reid Kleckner2016-02-091-10/+0
| | | | | | | | | | instantiation" This reverts commit r260194. It caused PR26549. There's probably a better way to do this also. llvm-svn: 260241
* [OPENMP] Allow to use the variable in the same 'threadprivate'Alexey Bataev2016-02-091-3/+0
| | | | | | directive. llvm-svn: 260215
* Do not mark variable as threadprivate if it was marked already.Alexey Bataev2016-02-091-0/+3
| | | | llvm-svn: 260214
* [OPENMP] Allow to reference threadprivate variable in same directive.Alexey Bataev2016-02-091-2/+8
| | | | llvm-svn: 260213
* Avoid forcing emission of delayed dllexported classes on template instantiationReid Kleckner2016-02-091-0/+10
| | | | | | Fixes PR26490 llvm-svn: 260194
* Make ParentMap work with explicit specializations of function templates.Nico Weber2016-02-081-1/+0
| | | | | | | | | | | | | | | | | For an explicit specialization, we first build a FunctionDecl, and then we call SubstDecl() on it to build a second FunctionDecl, which has the first FunctionDecl as canonical decl. The address of an explicit specialization of function template used to be the canonical decl of the FunctionDecl. This is different from all the other DeduceTemplateArguments() calls in SemaOverload, and since the canonical decl isn't visited by ParentMap while the redecl is, it also made ParentMap assert when computing the parent of a address-of-explicit-specialization-fun-template. To fix, remove the getCanonicalDecl() call. No behavior difference for clang, but it fixes an assert in ParentMap (which is e.g. used by libTooling). llvm-svn: 260159
* [Concepts] Remove the IsConcept bit and associated member functions from VarDeclNathan Wilson2016-02-081-5/+8
| | | | | | because the information is now stored in TemplateDecl. llvm-svn: 260155
* Remove dead code.Richard Smith2016-02-081-4/+0
| | | | llvm-svn: 260124
* [OPENMP 4.5] Ccapture/codegen of private non-static data members.Alexey Bataev2016-02-084-22/+94
| | | | | | | OpenMP 4.5 introduces privatization of non-static data members of current class in non-static member functions. To correctly handle such kind of privatization a new (pseudo)declaration VarDecl-based node is added. It allows to reuse an existing code for capturing variables in Lambdas/Block/Captured blocks of code for correct privatization and codegen. llvm-svn: 260077
* [Concepts] Implement a portion of Concepts TS[dcl.spec.concept]p1 byNathan Wilson2016-02-082-2/+32
| | | | | | | | | | | | | | diagnosing when 'concept' is specified on a function or template specialization. Since a concept can only be applied to a function or variable template, the concept bit is stored in TemplateDecl as a PointerIntPair. Reviewers: rsmith, faisalv, aaron.ballman, hubert.reinterpretcast Differential Revision: http://reviews.llvm.org/D13357 llvm-svn: 260074
* Sema: handle typo correction on ARC'ed ivarSaleem Abdulrasool2016-02-071-0/+4
| | | | | | | | | | | The ivar ref would be transformed by the Typo Correction TreeTransform, but not be owned, resulting in the source location being invalid. This would eventually lead to an assertion in findCapturingExpr. Prevent this assertion from triggering. Resolves PR25113. llvm-svn: 260017
* Sema: handle typo correction with ARC'ed objc propertiesSaleem Abdulrasool2016-02-071-0/+4
| | | | | | | | | | | | | We would previously assert in findCapturingExpr when performing a typo correction resulting in an assignment of an ObjC property with a strong lifetype specifier due to the expression not being rooted in the file (invalid SLoc) during the retain cycle check on the typo-corrected expression. Handle the expression type appropriately during the TreeTransform to ensure that we have a source location associated with the expression. Fixes PR26486. llvm-svn: 260016
* Exempt char array initializers from -Wconstant-converion.Richard Trieu2016-02-051-24/+39
| | | | | | | | Sometimes, char arrays are used as bit storage, with no difference made between signed and unsigned char. Thus, it is reasonable to use 0 to 255 instead of -128 to 127 and not trigger this warning. llvm-svn: 259947
* [modules] Separately track whether an identifier's preprocessor information andRichard Smith2016-02-051-1/+1
| | | | | | | | | | name lookup information have changed since deserialization. For a C++ modules build, we do not need to re-emit the identifier into the serialized identifier table if only the name lookup information has changed (and in all cases, we don't need to re-emit the macro information if only the name lookup information has changed). llvm-svn: 259901
* Don't synthesize an ImportDecl for a module named in -fmodule-implementation-ofBen Langmuir2016-02-051-1/+7
| | | | | | | | | | When building a PCH with modules enabled this import would assert in the ASTWriter and (if assertions were disabled) sometimes crash the compiler that loaded the resulting PCH when trying to lookup the submodule ID. rdar://problem/24137448 llvm-svn: 259859
* Fix a crash when there is a typo in the return statement.Manman Ren2016-02-041-0/+5
| | | | | | | | | | | | | | If the typo happens after a successful deduction for an earlier return statement, we should check if the deduced type is null before using it. The typo correction happens after we try to deduce the return type and we ignore the deduction from the typo and continue to typo correction. rdar://24342247 llvm-svn: 259820
* [OPENMP 4.0] Fixed support of array sections/array subscripts.Alexey Bataev2016-02-042-5/+23
| | | | | | Codegen for array sections/array subscripts worked only for expressions with arrays as base. Patch fixes codegen for bases with pointer/reference types. llvm-svn: 259776
* Fix predefine for __NSConstantString struct typeBen Langmuir2016-02-041-4/+5
| | | | | | | | | | | | | | | | | Per review feedback the name was wrong and it can be used outside Objective-C. Unfortunately, making the internal struct visible broke some ASTMatchers tests that assumed that the first record decl would be from user code, rather than a builtin type. I'm worried that this will also affect users' code. So this patch adds a typedef to wrap the internal struct and only makes the typedef visible to namelookup. This is sufficient to allow the ASTReader to merge the decls we need without making the struct itself visible. rdar://problem/24425801 llvm-svn: 259734
* Reapply r259624, it is likely not the commit causing the bot failures.Quentin Colombet2016-02-031-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Original message: Make CF constant string decl visible to name lookup to fix module errors The return type of the __builtin___*StringMakeConstantString functions is a pointer to a struct, so we need that struct to be visible to name lookup so that we will correctly merge multiple declarations of that type if they come from different modules. Incidentally, to make this visible to name lookup we need to rename the type to __NSConstantString, since the real NSConstantString is an Objective-C interface type. This shouldn't affect anyone outside the compiler since users of the constant string builtins cast the result immediately to CFStringRef. Since this struct type is otherwise implicitly created by the AST context and cannot access namelookup, we make this a predefined type and initialize it in Sema. Note: this issue of builtins that refer to types not visible to name lookup technically also affects other builtins (e.g. objc_msgSendSuper), but in all other cases the builtin is a library builtin and the issue goes away if you include the library that defines the types it uses, unlike for these constant string builtins. rdar://problem/24425801 llvm-svn: 259721
* Revert r259624 - Make CF constant string decl visible to name lookup to fix ↵Quentin Colombet2016-02-031-4/+0
| | | | | | | | | module errors. This breaks some internal bots in stage2: clang seg fault. Looking with Ben to see what is going on. llvm-svn: 259715
* Ensure that we substitute into the declaration of a template parameter packRichard Smith2016-02-031-4/+32
| | | | | | | (that is not a pack expansion) during template argument deduction, even if we deduced that the pack would be empty. llvm-svn: 259688
* Refactor conversion of deduced template arguments to reduce repetition.Richard Smith2016-02-031-103/+49
| | | | llvm-svn: 259687
* [Sema debugger support] Require non-void types to be complete in ↵Douglas Gregor2016-02-031-0/+6
| | | | | | | | | | unknown-anytype casts. When performing a cast from an __unknown_anytype function call to a non-void type, we need to make sure that type is complete. Fixes rdar://problem/23959960. llvm-svn: 259681
OpenPOWER on IntegriCloud