summaryrefslogtreecommitdiffstats
path: root/clang/test/CodeGenObjC
Commit message (Collapse)AuthorAgeFilesLines
...
* Emit calls to objc_unsafeClaimAutoreleasedReturnValue whenJohn McCall2016-01-271-0/+231
| | | | | | | | | | | | | | | | | reclaiming a call result in order to ignore it or assign it to an __unsafe_unretained variable. This avoids adding an unwanted retain/release pair when the return value is not actually returned autoreleased (e.g. when it is returned from a nonatomic getter or a typical collection accessor). This runtime function is only available on the latest Apple OS releases; the backwards-compatibility story is that you don't get the optimization unless your deployment target is recent enough. Sorry. rdar://20530049 llvm-svn: 258962
* Objective-C properties: merge attributes when redeclaring 'readonly' as ↵Douglas Gregor2015-12-101-4/+12
| | | | | | | | | | | | | | 'readwrite' in an extension. r251874 stopped back-patching the AST when an Objective-C 'readonly' property is redeclared in a class extension as 'readwrite'. However, it did not properly handle merging of Objective-C property attributes (e.g., getter name, ownership, atomicity) to the redeclaration, leading to bad metadata. Merge (and check!) those property attributes so we get the right metadata and reasonable ASTs. Fixes rdar://problem/23823989. llvm-svn: 255309
* Fix debug info for Objective-C properties from class extensions after r251874Nico Weber2015-12-041-0/+48
| | | | | | | | | | | | | | | | | | | | | | | | | | | | After r251874, properties from class extensions no longer show up in ObjCInterfaceDecl::properties(). Make debug info emission explicitly look for properties in class extensions before looking at direct properties. Also add a test that checks for this. There are three interesting cases: 1. A property is only declared in a class extension, and the @implementation is in a different file. This used to generated a DIObjcProperty before r251874 and does again with this fix. 2. A property is declared as readonly in the class itself and redeclared as readwrite in a class extension. clang before r251874 put the DIObjcProperty on the first declaration. clang after r251874 didn't emit any DIObjcProperty, and clang with this fix puts it on the readwrite redeclaration (which is what lookup finds). This seems like a progression. 3. Like 2, but with an @implementation in the same file. In this case, the property debug info gets generated a second time through the ivar from the definition. In this case, lookup and declaration code need to agree on the line number so that the DIObjcProperty isn't emitted twice. In this case, clang before r251874 emitted one DIObjcProperty on the first declaration, clang with r251874 emitted one on the second declaration, and clang with this patch still does the latter. llvm-svn: 254750
* Fix Objective-C metadata for properties from class extensions after r251874Nico Weber2015-12-031-0/+39
| | | | | | | | | | | | After, properties from class extensions no longer show up in ObjCInterfaceDecl::properties(). Make ObjCCommonMac::EmitPropertyList() explicitly look for properties in class extensions before looking at direct properties. Also add a test that passes both with clang before r251874 and after this patch (but fails with r251874 and without this patch). llvm-svn: 254622
* Add -disable-llvm-passes for frontend debug info tests.Dehao Chen2015-11-201-6/+4
| | | | | | | | | | | | Summary: The frontend debuginfo tests should not invoke llvm passes which includes add-discriminators that will change the debug info generated by FE. Reviewers: dblaikie Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D14848 llvm-svn: 253686
* Update clang tests to accomendate discriminator changes.Dehao Chen2015-11-191-4/+5
| | | | | | | | | | Summary: The discriminator change in http://reviews.llvm.org/D14738 will fail these clang tests. Update the test to accomendate the discriminator change. Reviewers: dblaikie, davidxl, dnovillo Differential Revision: http://reviews.llvm.org/D14836 llvm-svn: 253595
* Revert "Change memcpy/memset/memmove to have dest and source alignments."Pete Cooper2015-11-195-8/+8
| | | | | | | | | | This reverts commit r253512. This likely broke the bots in: http://lab.llvm.org:8011/builders/clang-ppc64-elf-linux2/builds/20202 http://bb.pgr.jp/builders/clang-3stage-i686-linux/builds/3787 llvm-svn: 253542
* Don't actually add the __unsafe_unretained qualifier in MRC;John McCall2015-11-191-0/+29
| | | | | | | | | | | driving a canonical difference between that and an unqualified type is a really bad idea when both are valid. Instead, remember that it was there in a non-canonical way, then look for that in the one place we really care about it: block captures. The net effect closely resembles the behavior of a decl attribute, except still closely following ARC's standard qualifier parsing rules. llvm-svn: 253534
* Fix the emission of ARC-style ivar layouts in the fragile runtimeJohn McCall2015-11-191-0/+20
| | | | | | | | | to start at the offset of the first ivar instead of the rounded-up end of the superclass. The latter could include a large amount of tail padding because of a highly-aligned ivar, and subclass ivars can be laid out within that. llvm-svn: 253533
* Change memcpy/memset/memmove to have dest and source alignments.Pete Cooper2015-11-185-8/+8
| | | | | | | | | | | | | | | | | | | | | | This is a follow on from a similar LLVM commit: r253511. Note, this was reviewed (and more details are in) http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20151109/312083.html These intrinsics currently have an explicit alignment argument which is required to be a constant integer. It represents the alignment of the source and dest, and so must be the minimum of those. This change allows source and dest to each have their own alignments by using the alignment attribute on their arguments. The alignment argument itself is removed. The only code change to clang is hidden in CGBuilder.h which now passes both dest and source alignment to IRBuilder, instead of taking the minimum of dest and source alignments. Reviewed by Hal Finkel. llvm-svn: 253512
* Fix tests in order for them to not fail after r252604.Igor Laevsky2015-11-181-2/+2
| | | | | | | | Some expected attributes appear to be incorrect after optimizations are run and llvm will strip them. Use -O0 so that llvm will not have a chance to remove them. llvm-svn: 253458
* Correctly handle type mismatches in the __weak copy/move-initializationJohn McCall2015-11-161-0/+20
| | | | | | | | peephole I added in r250916. rdar://23559789 llvm-svn: 253255
* [C++] Add the "norecurse" attribute to main() if in C++ modeJames Molloy2015-11-121-1/+1
| | | | | | The C++ spec (3.6.1.3) says "The function `main` shall not be used within a program". This implies that it cannot recurse, so add the norecurse attribute to help the midend out a bit. llvm-svn: 252902
* Initialize @catch variables correctly in fragile-runtime ARC.John McCall2015-10-301-2/+39
| | | | llvm-svn: 251677
* Fix the emission of ARC ivar layouts in the non-fragile Mac runtime.John McCall2015-10-291-11/+25
| | | | | | | My previous change in this area accidentally broke the rule when InstanceBegin was not a multiple of the word size. llvm-svn: 251666
* Define weak and __weak to mean ARC-style weak references, even in MRC.John McCall2015-10-223-3/+145
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, __weak was silently accepted and ignored in MRC mode. That makes this a potentially source-breaking change that we have to roll out cautiously. Accordingly, for the time being, actual support for __weak references in MRC is experimental, and the compiler will reject attempts to actually form such references. The intent is to eventually enable the feature by default in all non-GC modes. (It is, of course, incompatible with ObjC GC's interpretation of __weak.) If you like, you can enable this feature with -Xclang -fobjc-weak but like any -Xclang option, this option may be removed at any point, e.g. if/when it is eventually enabled by default. This patch also enables the use of the ARC __unsafe_unretained qualifier in MRC. Unlike __weak, this is being enabled immediately. Since variables are essentially __unsafe_unretained by default in MRC, the only practical uses are (1) communication and (2) changing the default behavior of by-value block capture. As an implementation matter, this means that the ObjC ownership qualifiers may appear in any ObjC language mode, and so this patch removes a number of checks for getLangOpts().ObjCAutoRefCount that were guarding the processing of these qualifiers. I don't expect this to be a significant drain on performance; it may even be faster to just check for these qualifiers directly on a type (since it's probably in a register anyway) than to do N dependent loads to grab the LangOptions. rdar://9674298 llvm-svn: 251041
* Enable ARC on the fragile runtime.John McCall2015-10-211-0/+138
| | | | | | | | | | | | | | | | This is almost entirely a matter of just flipping a switch. 99% of the runtime support is available all the way back to when it was implemented in the non-fragile runtime, i.e. in Lion. However, fragile runtimes do not recognize ARC-style ivar layout strings, which means that accessing __strong or __weak ivars reflectively (e.g. via object_setIvar) will end up accessing the ivar as if it were __unsafe_unretained. Therefore, when using reflective technologies like KVC, be sure that your paths always refer to a property. rdar://23209307 llvm-svn: 250955
* Fix and stylize the emission of GC/ARC ivar and GC block layout strings.John McCall2015-10-212-1/+48
| | | | | | | | | | | | | | | Specifically, handle under-aligned object references (by explicitly ignoring them, because this just isn't representable in the format; yes, this means that GC silently ignores such references), descend into anonymous structs and unions, stop classifying fields of pointer-to-strong/weak type as strong/weak in ARC mode, and emit skips to cover the entirety of block layouts in GC mode. As a cleanup, extract this code into a helper class, avoid a number of unnecessary copies and layout queries, generate skips implicitly instead of explicitly tracking them, and clarify the bitmap-creation logic. llvm-svn: 250919
* In ARC, peephole the initialization of a __weak variable withJohn McCall2015-10-212-5/+2
| | | | | | | a value loaded from a __weak variable into a call to objc_copyWeak or objc_moveWeak. llvm-svn: 250916
* [CodeGen] [CodeGen] Attach function attributes to functions created inAkira Hatanaka2015-10-081-16/+16
| | | | | | | | | | | | | | | | | | CGBlocks.cpp. This commit fixes a bug in clang's code-gen where it creates the following functions but doesn't attach function attributes to them: __copy_helper_block_ __destroy_helper_block_ __Block_byref_object_copy_ __Block_byref_object_dispose_ rdar://problem/20828324 Differential Revision: http://reviews.llvm.org/D13525 llvm-svn: 249735
* Stop messing with the 'g' group of options in CompilerInvocation.Douglas Katzman2015-10-0849-52/+52
| | | | | | | | | | | | | | | | With this change, most 'g' options are rejected by CompilerInvocation. They remain only as Driver options. The new way to request debug info from cc1 is with "-debug-info-kind={line-tables-only|limited|standalone}" and "-dwarf-version={2|3|4}". In the absence of a command-line option to specify Dwarf version, the Toolchain decides it, rather than placing Toolchain-specific logic in CompilerInvocation. Also fix a bug in the Windows compatibility argument parsing in which the "rightmost argument wins" principle failed. Differential Revision: http://reviews.llvm.org/D13221 llvm-svn: 249655
* Don't nil check non-nil class receiver of AArch64 stret calls.Ahmed Bougacha2015-10-021-6/+9
| | | | | | | | | | | I randomly came across this difference between AArch64 and other targets: on the latter, we don't emit nil checks for known non-nil class method calls thanks to r247350, but we still do for AArch64 stret calls. They use different code paths, because those are special, as they go through the regular msgSend, not the msgSend*_stret variants. llvm-svn: 249205
* Be slightly more permissive when checking for type-erased blocks.Bob Wilson2015-10-021-0/+7
| | | | | | This is a patch from Doug that was inadvertently omitted from r241543. llvm-svn: 249116
* Add test coverage for @encode(SEL); completely untested until now.Nico Weber2015-09-151-0/+3
| | | | llvm-svn: 247717
* Rebase tests after LLVM r247707.Nico Weber2015-09-151-1/+1
| | | | llvm-svn: 247712
* Support noreturn in limited contexts on Objective-C message sends.John McCall2015-09-101-0/+99
| | | | | | rdar://6198039 llvm-svn: 247350
* ARC: Fix the precise-lifetime suppression of returns_inner_pointerJohn McCall2015-09-091-13/+142
| | | | | | | | receiver extension for message sends via property syntax. rdar://22172983 llvm-svn: 247209
* Compute and preserve alignment more faithfully in IR-generation.John McCall2015-09-0811-94/+78
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Introduce an Address type to bundle a pointer value with an alignment. Introduce APIs on CGBuilderTy to work with Address values. Change core APIs on CGF/CGM to traffic in Address where appropriate. Require alignments to be non-zero. Update a ton of code to compute and propagate alignment information. As part of this, I've promoted CGBuiltin's EmitPointerWithAlignment helper function to CGF and made use of it in a number of places in the expression emitter. The end result is that we should now be significantly more correct when performing operations on objects that are locally known to be under-aligned. Since alignment is not reliably tracked in the type system, there are inherent limits to this, but at least we are no longer confused by standard operations like derived-to-base conversions and array-to-pointer decay. I've also fixed a large number of bugs where we were applying the complete-object alignment to a pointer instead of the non-virtual alignment, although most of these were hidden by the very conservative approach we took with member alignment. Also, because IRGen now reliably asserts on zero alignments, we should no longer be subject to an absurd but frustrating recurring bug where an incomplete type would report a zero alignment and then we'd naively do a alignmentAtOffset on it and emit code using an alignment equal to the largest power-of-two factor of the offset. We should also now be emitting much more aggressive alignment attributes in the presence of over-alignment. In particular, field access now uses alignmentAtOffset instead of min. Several times in this patch, I had to change the existing code-generation pattern in order to more effectively use the Address APIs. For the most part, this seems to be a strict improvement, like doing pointer arithmetic with GEPs instead of ptrtoint. That said, I've tried very hard to not change semantics, but it is likely that I've failed in a few places, for which I apologize. ABIArgInfo now always carries the assumed alignment of indirect and indirect byval arguments. In order to cut down on what was already a dauntingly large patch, I changed the code to never set align attributes in the IR on non-byval indirect arguments. That is, we still generate code which assumes that indirect arguments have the given alignment, but we don't express this information to the backend except where it's semantically required (i.e. on byvals). This is likely a minor regression for those targets that did provide this information, but it'll be trivial to add it back in a later patch. I partially punted on applying this work to CGBuiltin. Please do not add more uses of the CreateDefaultAligned{Load,Store} APIs; they will be going away eventually. llvm-svn: 246985
* Fix CHECK directives that weren't checking.Hans Wennborg2015-08-311-1/+1
| | | | llvm-svn: 246492
* DI: Update DISubprogram testcases after LLVM r246098Duncan P. N. Exon Smith2015-08-262-5/+5
| | | | llvm-svn: 246099
* Internal-linkage variables with constant-evaluatable initializers do not ↵Richard Smith2015-08-191-1/+9
| | | | | | need to be emitted. (Also reduces the set of variables that need to be eagerly deserialized when using PCH / modules.) llvm-svn: 245497
* DI: Update testcases for LLVM assembly changeDuncan P. N. Exon Smith2015-07-318-17/+18
| | | | | | | | | | Update testcases after LLVM change r243774. Most of these had no need to check `tag:` field, but did so as a way of getting to the `name:` field. In a few cases I've converted the `tag:` checks to `arg:` or `CHECK-NOT: arg:`. llvm-svn: 243775
* Add missing files for objc_boxable feature.Alex Denisov2015-07-235-0/+551
| | | | | | Original patch [r240761] is missing all new files because of committer's mistake. llvm-svn: 243018
* Fix -save-temp when using objc-arc, sanitizer and profilingSteven Wu2015-07-171-0/+27
| | | | | | | | | | | | Currently, -save-temp will cause ObjCARC optimization to be dropped, sanitizer pass to run early in the pipeline, and profiling instrumentation to run twice. Fix the issue by properly disable all passes in the optimization pipeline when generating bitcode output and parse some of the Language Options even when the input is bitcode so the passes can be setup correctly. llvm-svn: 242565
* Substitute type arguments into uses of Objective-C interface members.Douglas Gregor2015-07-071-0/+63
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Account for calling convention specifiers in function definitions in IR test ↵David Blaikie2015-06-293-10/+10
| | | | | | | | | | | | | cases Several tests wouldn't pass when executed on an armv7a_pc_linux triple due to the non-default arm_aapcs calling convention produced on the function definitions in the IR output. Account for this with the application of a little regex. Patch by Ying Yi. llvm-svn: 240971
* Update clang to take into account the changes to personality fnsDavid Majnemer2015-06-174-6/+9
| | | | llvm-svn: 239941
* Honor the objc_runtime_name attribute when encoding class/protocol names.Douglas Gregor2015-06-161-1/+15
| | | | | | | | While the rest of the Objective-C metadata seems to honor objc_runtime_name, the encoding strings produced by, e.g., @encode and property meta, were not. Fixes rdar://problem/21408305. llvm-svn: 239852
* Adjust clang side tests effected by 239795 before reapplying said changePhilip Reames2015-06-162-12/+12
| | | | llvm-svn: 239848
* Implement no_sanitize attribute.Peter Collingbourne2015-05-151-0/+8
| | | | | | Differential Revision: http://reviews.llvm.org/D9631 llvm-svn: 237463
* Changed renaming of local symbols by inserting a dot vefore the numeric suffixSunil Srivastava2015-05-1213-20/+20
| | | | | | | details in http://reviews.llvm.org/D9483 goes with llvm checkin r237150 llvm-svn: 237151
* DebugInfo: Metadata constructs now start with DI*Duncan P. N. Exon Smith2015-04-2930-104/+104
| | | | | | | | | | LLVM r236120 renamed debug info IR constructs to use a `DI` prefix, now that the `DIDescriptor` hierarchy has been gone for about a week. This commit was generated using the rename-md-di-nodes.sh upgrade script attached to PR23080, followed by running clang-format-diff.py on the `lib/` portion of the patch. llvm-svn: 236121
* [opaque pointer type] Update test cases now that the type for an invoke is ↵David Blaikie2015-04-241-1/+1
| | | | | | just a function type, not a pointer-to-function type llvm-svn: 235756
* Revert "Revert r234581, it might have caused a few miscompiles in Chromium."David Majnemer2015-04-227-13/+190
| | | | | | | | This reverts commit r234700. It turns out that the lifetime markers were not the cause of Chromium failing but a bug which was uncovered by optimizations exposed by the markers. llvm-svn: 235553
* [opaque pointer types] Explicit non-pointer type for call expressionsDavid Blaikie2015-04-1610-18/+18
| | | | | | (migration for recent LLVM change to textual IR for calls) llvm-svn: 235147
* Revert r234581, it might have caused a few miscompiles in Chromium.Nico Weber2015-04-117-190/+13
| | | | | | | If the revert helps, I'll get a repro this Monday. Else I'll put the change back in. llvm-svn: 234700
* Remove threshold for inserting lifetime markers for named temporariesArnaud A. de Grandmaison2015-04-107-13/+190
| | | | | | | | | | | | | | | | | | | Now that TailRecursionElimination has been fixed with r222354, the threshold on size for lifetime marker insertion can be removed. This only affects named temporary though, as the patch for unnamed temporaries is still in progress. My previous commit (r222993) was not handling debuginfo correctly, but this could only be seen with some asan tests. Basically, lifetime markers are just instrumentation for the compiler's usage and should not affect debug information; however, the cleanup infrastructure was assuming it contained only destructors, i.e. actual code to be executed, and was setting the breakpoint for the end of the function to the closing '}', and not the return statement, in order to show some destructors have been called when leaving the function. This is wrong when the cleanups are only lifetime markers, and this is now fixed. llvm-svn: 234581
* [Objective-C patch] Patch to fix a crash in IRGen because Fariborz Jahanian2015-04-061-0/+21
| | | | | | | | of incorrect AST when a compound literal of Objective-C property access is used to initialize a vertor of floats. rdar://20407999 llvm-svn: 234176
* [Objective-C metadata patch]. Patch to allocate one more space for Fariborz Jahanian2015-03-311-0/+17
| | | | | | Protocol objects in OBJC2. rdar://20286356 llvm-svn: 233766
* Test case updates for explicit type parameter to the gep operatorDavid Blaikie2015-03-139-21/+21
| | | | llvm-svn: 232187
OpenPOWER on IntegriCloud