summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaExprObjC.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Remove trailing spaceFangrui Song2018-07-301-190/+190
| | | | | | sed -Ei 's/[[:space:]]+$//' include/**/*.{def,h,td} lib/**/*.{cpp,h} llvm-svn: 338291
* [Sema][ObjC] Do not propagate the nullability specifier on the receiverAkira Hatanaka2018-07-261-0/+5
| | | | | | | | | | | | | | | | | | to the result type of a message send if the result type cannot have a nullability specifier. Previously, clang would print the following message when the code in nullability.m was compiled: "incompatible integer to pointer conversion initializing 'int *' with an expression of type 'int _Nullable'" This is wrong as 'int' isn't supposed to have any nullability specifiers. rdar://problem/40830514 llvm-svn: 338048
* DR1687: When overload resolution selects a built-in operator, implicitRichard Smith2018-06-271-6/+8
| | | | | | | | | | | conversions are only applied to operands of class type, and the second standard conversion sequence is not applied. When diagnosing an invalid builtin binary operator, talk about the original types rather than the converted types. If these differ by a user-defined conversion, tell the user what happened. llvm-svn: 335781
* Remove \brief commands from doxygen comments.Adrian Prantl2018-05-091-9/+9
| | | | | | | | | | | | | | | | | | | This is similar to the LLVM change https://reviews.llvm.org/D46290. We've been running doxygen with the autobrief option for a couple of years now. This makes the \brief markers into our comments redundant. Since they are a visual distraction and we don't want to encourage more \brief markers in new code either, this patch removes them all. Patch produced by for i in $(git grep -l '\@brief'); do perl -pi -e 's/\@brief //g' $i & done for i in $(git grep -l '\\brief'); do perl -pi -e 's/\\brief //g' $i & done Differential Revision: https://reviews.llvm.org/D46320 llvm-svn: 331834
* Fix typos in clangAlexander Kornienko2018-04-061-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Found via codespell -q 3 -I ../clang-whitelist.txt Where whitelist consists of: archtype cas classs checkk compres definit frome iff inteval ith lod methode nd optin ot pres statics te thru Patch by luzpaz! (This is a subset of D44188 that applies cleanly with a few files that have dubious fixes reverted.) Differential revision: https://reviews.llvm.org/D44188 llvm-svn: 329399
* [Sema] Make deprecation fix-it replace all multi-parameter ObjC method slots.Volodymyr Sapsai2018-03-291-12/+14
| | | | | | | | | | | | | | | | | | Deprecation replacement can be any text but if it looks like a name of ObjC method and has the same number of arguments as original method, replace all slot names so after applying a fix-it you have valid code. rdar://problem/36660853 Reviewers: aaron.ballman, erik.pilkington, rsmith Reviewed By: erik.pilkington Subscribers: cfe-commits, jkorous-apple Differential Revision: https://reviews.llvm.org/D44589 llvm-svn: 328807
* Add an option to disable tail-call optimization for escaping blocks.Akira Hatanaka2018-03-021-0/+5
| | | | | | | | | | | | | This makes it easier to debug crashes and hangs in block functions since users can easily find out where the block is called from. The option doesn't disable tail-calls from non-escaping blocks since non-escaping blocks are not as hard to debug as escaping blocks. rdar://problem/35758207 Differential Revision: https://reviews.llvm.org/D43841 llvm-svn: 326530
* Track in the AST whether the operand to a UnaryOperator can overflow and ↵Aaron Ballman2018-01-091-3/+3
| | | | | | then use that logic when evaluating constant expressions and emitting codegen. llvm-svn: 322074
* Silence a bunch of implicit fallthrough warningsAdrian Prantl2017-12-191-0/+1
| | | | llvm-svn: 321115
* [ObjC] Boxed strings should use the nullability from stringWithUTF8String's ↵Alex Lorenz2017-11-081-0/+7
| | | | | | | | | | | | | | | | | | return type Objective-C NSString has a class method stringWithUTF8String that creates a new NSString from a C string. Objective-C box expression @(...) can be used to create an NSString instead of invoking the stringWithUTF8String method directly (The compiler lowers it down to the invocation though). This commit ensures that the type of @(string-value) gets the same nullability attributes as the return type of stringWithUTF8String to ensure that the diagnostics are consistent between the two. rdar://33847186 Differential Revision: https://reviews.llvm.org/D39762 llvm-svn: 317727
* [Sema][ObjC] Preserve syntactic sugar when removingAkira Hatanaka2017-10-101-8/+31
| | | | | | | | | | | | | | | | | ARCReclaimReturnedObject cast. This is a follow-up to r314370. Rather than throwing away the enclosing parentheses, this commit walks down the expression until an ARCReclaimReturnedObject cast is found and removes just the cast, preserving the syntactic sugar expressions (parens and casts) that were visited up to that point. rdar://problem/34705720 Differential Revision: https://reviews.llvm.org/D38659 llvm-svn: 315261
* Look through parentheses.Akira Hatanaka2017-09-281-1/+1
| | | | | | | | | This fixes a bug where clang would emit instructions to reclaim a value that's going to be __bridge-casted to CF. rdar://problem/34687542 llvm-svn: 314370
* [ObjC] Add a -Wobjc-messaging-id warningAlex Lorenz2017-08-251-0/+3
| | | | | | | | | | | | -Wobjc-messaging-id is a new, non-default warning that warns about message sends to unqualified id in Objective-C. This warning is useful for projects that would like to avoid any potential future compiler errors/warnings, as the system frameworks might add a method with the same selector which could make the message send to id ambiguous. rdar://33303354 llvm-svn: 311779
* [Sema][ObjC] Clean up possible null dereference.Akira Hatanaka2017-05-091-2/+1
| | | | | | | | | | | | It appears that the code is actually dead since unbridged-cast placeholder types are created by calling CastOperation::complete and ImplicitCastExprs are never passed to it. Spotted by Vedant Kumar. rdar://problem/31542226 llvm-svn: 302503
* ObjCBoxedExpr can't be evaluated by the constant expression evaluator.Nick Lewycky2017-04-291-1/+0
| | | | | | | | A boxed expression evaluates its subexpr and then calls an objc method to transform it into another value with pointer type. The objc method can never be constexpr and therefore this expression can never be evaluated. Fixes a miscompile boxing expressions with side-effects. Also make ObjCBoxedExpr handling a normal part of the expression evaluator instead of being the only case besides full-expression where we check for integer overflow. llvm-svn: 301721
* [Sema][ObjC] Check whether a variable has a definition, rather thanAkira Hatanaka2017-04-111-1/+1
| | | | | | | | | | | | | | | | checking its storage class, when determining whether casting a C pointer to an ObjC pointer is allowed. This change allows casting variables whose declarations are directly contained in a linkage specification to an ObjC pointer type. Those variables are treated as if they contain the extern specifier for the purpose of determining whether they are definitions or not. rdar://problem/29249853 Differential Revision: https://reviews.llvm.org/D31673 llvm-svn: 299992
* [Objective-C] Fix "weak-unavailable" warning with -fobjc-weakBrian Kelley2017-03-291-6/+10
| | | | | | | | | | | | | | Summary: clang should produce the same errors Objective-C classes that cannot be assigned to weak pointers under both -fobjc-arc and -fobjc-weak. Check for ObjCWeak along with ObjCAutoRefCount when analyzing pointer conversions. Add an -fobjc-weak pass to the existing arc-unavailable-for-weakref test cases to verify the behavior is the same. Reviewers: rsmith, doug.gregor, rjmccall Reviewed By: rjmccall Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D31006 llvm-svn: 299014
* [Objective-C] Fix "repeated use of weak" warning with -fobjc-weakBrian Kelley2017-03-291-0/+2
| | | | | | | | | | | | | | Summary: -Warc-repeated-use-of-weak should produce the same warnings with -fobjc-weak as it does with -objc-arc. Also check for ObjCWeak along with ObjCAutoRefCount when recording the use of an evaluated weak variable. Add a -fobjc-weak run to the existing arc-repeated-weak test case and adapt it slightly to work in both modes. Reviewers: rsmith, doug.gregor, jordan_rose, rjmccall Reviewed By: rjmccall Subscribers: arphaman, rjmccall, cfe-commits Differential Revision: https://reviews.llvm.org/D31005 llvm-svn: 299011
* [ObjC][ARC] Avoid -Warc-performSelector-leaks for performSelector variationsAlex Lorenz2017-03-231-1/+2
| | | | | | | | | | | | | | | | that became supported after r297019 The commit r297019 expanded the performSelector ObjC method family heuristic to ensure that -Wobjc-unsafe-perform-selector covers all performSelector variations. However, this made the -Warc-performSelector-leaks too noisy, as that warning produces mostly false positives since the selector is unknown. This commit reverts the ObjC method family heuristics introduced in r297019. This ensures that -Warc-performSelector-leaks isn't too noisy. The commit still preserves the coverage of -Wobjc-unsafe-perform-selector. rdar://31124629 llvm-svn: 298587
* [ObjC][Sema] Avoid ARC performSelector error for 'self' selectorAlex Lorenz2017-03-161-1/+0
| | | | | | | | | The instance method 'self' does not actually return an over-retained object, so we shouldn't report an error when it's used with 'performSelector'. rdar://31071620 llvm-svn: 297961
* [ObjC][Sema] Avoid warning about a call to an instance method on anAlex Lorenz2017-03-151-1/+19
| | | | | | | | | | | | | | | | instance of a qualified Class object when that instance method comes from a protocol that's implemented by NSObject Instance methods from a root class like NSObject are also class methods because the metaclass of root class derives from that root class. Therefore, we can avoid the warning for instances of qualified Class objects that point to classes that derive from NSObject. Note that we actually don't know if a Class instance points to a class that derives from NSObject at compile-time, so we have to make a reasonable assumption that the majority of instances will do so. rdar://22812517 llvm-svn: 297862
* [Sema][ObjC] Warn about 'performSelector' calls with selectorsAlex Lorenz2017-03-061-0/+69
| | | | | | | | | | | | | | | | | | | that return record or vector types The performSelector family of methods from Foundation use objc_msgSend to dispatch the selector invocations to objects. However, method calls to methods that return record types might have to use the objc_msgSend_stret as the return value won't find into the register. This is also supported by this sentence from performSelector documentation: "The method should not have a significant return value and should take a single argument of type id, or no arguments". This commit adds a new warning that warns when a selector which corresponds to a method that returns a record type is passed into performSelector. rdar://12056271 Differential Revision: https://reviews.llvm.org/D30174 llvm-svn: 297019
* Sema: use PropertyDecl for property selectorSaleem Abdulrasool2017-02-201-8/+14
| | | | | | | | | | | Using the constructed name for the class properties with dot syntax may yield an inappropriate selector (i.e. if it is specified via property attributes). Prefer the declaration for the selector, falling back to the constructed name otherwise. Patch by David Herzka! llvm-svn: 295683
* [Sema][ObjC] perform-selector ARC check should see @selector in parensAlex Lorenz2017-02-201-1/+2
| | | | llvm-svn: 295674
* More diagnostic name fixups: w_ -> warn_, warning_ -> warn_, not_ -> note_.Richard Smith2016-12-021-2/+2
| | | | | | In passing, add a warning group for "ignored qualifier in inline assembly" warnings. llvm-svn: 288548
* Mass-rename the handful of error_* diagnostics to err_*.Richard Smith2016-12-021-4/+4
| | | | llvm-svn: 288545
* Add an assert to further check the invariant that a null pointerChandler Carruth2016-11-041-0/+4
| | | | | | | | | | | corresponds to another argument being valid. This makes it clear that the code is correct despite the PVS-Studio report that a pointer might be dereferenced prior to being checked for whether it is null. It likely is also enough for static analyzers to not flag the code. llvm-svn: 285982
* Fix typos in comments.George Burgess IV2016-09-011-3/+3
| | | | llvm-svn: 280333
* ObjC Class Property: diagnostics when accessing a class property using instance.Manman Ren2016-06-281-7/+24
| | | | | | | | | | | | | When a class property is accessed with an object instance, before this commit, we try to apply a typo correction of the same property: property 'c' not found on object of type 'A *'; did you mean 'c'? With this commit, we correctly emit a diagnostics: property 'c' is a class property; did you mean to access it with class 'A'? rdar://26866973 llvm-svn: 274076
* Re-commit "[Temporary] Add an ExprWithCleanups for each C++ ↵Tim Shen2016-06-211-2/+2
| | | | | | | | | | MaterializeTemporaryExpr." Since D21243 fixes relative clang-tidy tests. This reverts commit a71d9fbd41e99def9159af2b01ef6509394eaeed. llvm-svn: 273312
* Revert "[Temporary] Add an ExprWithCleanups for each C++ ↵Tim Shen2016-06-091-2/+2
| | | | | | | | | MaterializeTemporaryExpr." This reverts r272296, since there are clang-tidy failures that appear to be caused by this change. llvm-svn: 272310
* [Temporary] Add an ExprWithCleanups for each C++ MaterializeTemporaryExpr.Tim Shen2016-06-091-2/+2
| | | | | | | | | | | These ExprWithCleanups are added for holding a RunCleanupsScope not for destructor calls; rather, they are for lifetime marks. This requires ExprWithCleanups to keep a bit to indicate whether it have cleanups with side effects (e.g. dtor calls). Differential Revision: http://reviews.llvm.org/D20498 llvm-svn: 272296
* [ObjC kindof] Use type bound to filter out the candidate methods.Manman Ren2016-04-071-3/+2
| | | | | | rdar://21306753 llvm-svn: 265712
* NFC: simplify code in BuildInstanceMessage.Manman Ren2016-04-071-36/+52
| | | | | | | | | | | | | | | | Instead of searching the global pool multiple times: in LookupFactoryMethodInGlobalPool, LookupInstanceMethodInGlobalPool, CollectMultipleMethodsInGlobalPool, and AreMultipleMethodsInGlobalPool, we now collect the method candidates in CollectMultipleMethodsInGlobalPool only, and other functions will use the collected method set. This commit adds parameter "Methods" to AreMultipleMethodsInGlobalPool, and SelectBestMethod. It also changes the implementation of CollectMultipleMethodsInGlobalPool to collect the desired kind first, if none is found, to collect the other kind. This avoids the need to call both LookupFactoryMethodInGlobalPool and LookupInstanceMethodInGlobalPool. llvm-svn: 265711
* [Sema] More changes to fix Objective-C fallout from r249995.Bob Wilson2016-02-131-28/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Fix remaining Clang-tidy readability-redundant-control-flow warnings; other ↵Eugene Zelenko2016-02-121-10/+4
| | | | | | | | minor fixes. Differential revision: http://reviews.llvm.org/D17218 llvm-svn: 260757
* Class Property: class property and instance property can have the same name.Manman Ren2016-01-281-4/+7
| | | | | | | | | | | | | | | | | | | 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
* OpaquePtr: Use nullptr construction for ParsedType OpaquePtr typedefDavid Blaikie2016-01-151-1/+1
| | | | llvm-svn: 257958
* [Sema] Suppress diags in overload resolution.George Burgess IV2016-01-131-59/+75
| | | | | | | | | | We were emitting diagnostics from our shiny new C-only overload resolution mode. This patch attempts to silence all such diagnostics. This fixes PR26085. Differential Revision: http://reviews.llvm.org/D16159 llvm-svn: 257710
* Properly track that a character literal is UTF-8, and pretty print the ↵Aaron Ballman2016-01-071-0/+2
| | | | | | prefix properly. llvm-svn: 257097
* [TrailingObjects] Convert classes in ExprObjC.hJames Y Knight2015-12-311-3/+3
| | | | llvm-svn: 256659
* [Sema] ArrayRef-ize BuildObjCDictionaryLiteral. NFCCraig Topper2015-12-241-15/+14
| | | | llvm-svn: 256398
* [Sema] ArrayRef-ize ParseObjCStringLiteral and ↵Craig Topper2015-12-241-8/+5
| | | | | | CodeCompleteObjCProtocolReferences. NFC llvm-svn: 256397
* Split RequireCompleteType into a function that actually requires that the typeRichard Smith2015-12-181-0/+2
| | | | | | | | | | | | | | | | | | | is complete (with an error produced if not) and a function that merely queries whether the type is complete. Either way we'll trigger instantiation if necessary, but only the former will diagnose and recover from missing module imports. The intent of this change is to prevent a class of bugs where code would call RequireCompleteType(..., 0) and then ignore the result. With modules, we must check the return value and use it to determine whether the definition of the type is visible. This also fixes a debug info quality issue: calls to isCompleteType do not trigger the emission of debug information for a type in limited-debug-info mode. This allows us to avoid emitting debug information for type definitions in more cases where we believe it is safe to do so. llvm-svn: 256049
* Use Sema::getLocForEndOfToken instead of Preprocessor::getLocForEndOfToken. NFCCraig Topper2015-11-151-6/+6
| | | | llvm-svn: 253155
* Stop back-patching 'readonly' Objective-C properties with 'readwrite' ones.Douglas Gregor2015-11-031-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | A 'readonly' Objective-C property declared in the primary class can effectively be shadowed by a 'readwrite' property declared within an extension of that class, so long as the types and attributes of the two property declarations are compatible. Previously, this functionality was implemented by back-patching the original 'readonly' property to make it 'readwrite', destroying source information and causing some hideously redundant, incorrect code. Simplify the implementation to express how this should actually be modeled: as a separate property declaration in the extension that shadows (via the name lookup rules) the declaration in the primary class. While here, correct some broken Fix-Its, eliminate a pile of redundant code, clean up the ARC migrator's handling of properties declared in extensions, and fix debug info's naming of methods that come from categories. A wonderous side effect of doing this write is that it eliminates the "AddedObjCPropertyInClassExtension" method from the AST mutation listener, which in turn eliminates the last place where we rewrite entire declarations in a chained PCH file or a module file. This change (which fixes rdar://problem/18475765) will allow us to eliminate the rewritten-decls logic from the serialization library, and fixes a crash (rdar://problem/23247794) illustrated by the test/PCH/chain-categories.m example. llvm-svn: 251874
* Refine r251469 to give better (and more localizable) diagnosticsJohn McCall2015-10-281-1/+1
| | | | | | for all the reasons that ARC makes things implicitly unavailable. llvm-svn: 251496
* Be slightly more permissive when checking for type-erased blocks.Bob Wilson2015-10-021-1/+2
| | | | | | This is a patch from Doug that was inadvertently omitted from r241543. llvm-svn: 249116
* Silence a "not all control paths return a value" warning from MSVC. Should ↵Aaron Ballman2015-07-241-1/+2
| | | | | | also silence a -Wreturn-type warning. NFC intended. llvm-svn: 243109
* Cleanup ObjCInterfaceDecl lookup for ObjC literalsAlex Denisov2015-07-241-99/+98
| | | | llvm-svn: 243092
OpenPOWER on IntegriCloud