aboutsummaryrefslogtreecommitdiff
path: root/clang/test/CodeGenObjC
AgeCommit message (Collapse)AuthorFilesLines
2023-08-28[clang] Remove rdar links; NFCAaron Ballman139-235/+24
We have a new policy in place making links to private resources something we try to avoid in source and test files. Normally, we'd organically switch to the new policy rather than make a sweeping change across a project. However, Clang is in a somewhat special circumstance currently: recently, I've had several new contributors run into rdar links around test code which their patch was changing the behavior of. This turns out to be a surprisingly bad experience, especially for newer folks, for a handful of reasons: not understanding what the link is and feeling intimidated by it, wondering whether their changes are actually breaking something important to a downstream in some way, having to hunt down strangers not involved with the patch to impose on them for help, accidental pressure from asking for potentially private IP to be made public, etc. Because folks run into these links entirely by chance (through fixing bugs or working on new features), there's not really a set of problematic links to focus on -- all of the links have basically the same potential for causing these problems. As a result, this is an omnibus patch to remove all such links. This was not a mechanical change; it was done by manually searching for rdar, radar, radr, and other variants to find all the various problematic links. From there, I tried to retain or reword the surrounding comments so that we would lose as little context as possible. However, because most links were just a plain link with no supporting context, the majority of the changes are simple removals. Differential Review: https://reviews.llvm.org/D158071
2023-08-09Intrinsics: Add type overload to stacksave and stackstoreMatt Arsenault1-4/+4
This allows use with non-0 address space stacks. llvm_ptr_ty should never be used. This could use some more percolation up through mlir, but this is enough to fix existing tests. https://reviews.llvm.org/D156666
2023-08-01[Intrinsics][ObjC] Mark objc_retain and friends as thisreturn.Jon Roelofs2-10/+15
https://clang.llvm.org/docs/AutomaticReferenceCounting.html#arc-runtime-objc-retain rdar://79869679 Differential revision: https://reviews.llvm.org/D105671
2023-07-17Revert "Remove rdar links; NFC"Mehdi Amini137-24/+230
This reverts commit d618f1c3b12effd0c2bdb7d02108d3551f389d3d. This commit wasn't reviewed ahead of time and significant concerns were raised immediately after it landed. According to our developer policy this warrants immediate revert of the commit. https://llvm.org/docs/DeveloperPolicy.html#patch-reversion-policy Differential Revision: https://reviews.llvm.org/D155509
2023-07-07Remove rdar links; NFCAaron Ballman137-230/+24
This removes links to rdar, which is an internal bug tracker that the community doesn't have visibility into. See further discussion at: https://discourse.llvm.org/t/code-review-reminder-about-links-in-code-commit-messages/71847
2023-06-12[DebugMetadata] Simplify handling subprogram's retainedNodes field. NFCI (1/7)Vladislav Dzhidzhoev1-4/+4
RFC https://discourse.llvm.org/t/rfc-dwarfdebug-fix-and-improve-handling-imported-entities-types-and-static-local-in-subprogram-and-lexical-block-scopes/68544 Currently, `retainedNodes` tracks function-local variables and labels. To support function-local import, types and static variables (which are globals in LLVM IR), subsequent patches use the same field. So this patch makes preliminary refactoring of the code tracking local entities to apply future functional changes lucidly and cleanly. No functional changes intended. Differential Revision: https://reviews.llvm.org/D143984 Authored-by: Kristina Bessonova <kbessonova@accesssoftek.com>
2023-06-09Remove unnecessary metadata check in testAkira Hatanaka1-3/+3
2023-06-08Revert "[DebugMetadata] Simplify handling subprogram's retainedNodes field. ↵Vladislav Dzhidzhoev1-4/+4
NFCI (1/7)" This reverts commit 4418434c6de7a861e241ba2448ea4a12080cf08f. Reverted because it breaks tests of OCaml bindings.
2023-06-07[DebugMetadata] Simplify handling subprogram's retainedNodes field. NFCI (1/7)Kristina Bessonova1-4/+4
RFC https://discourse.llvm.org/t/rfc-dwarfdebug-fix-and-improve-handling-imported-entities-types-and-static-local-in-subprogram-and-lexical-block-scopes/68544 Currently, `retainedNodes` tracks function-local variables and labels. To support function-local import, types and static variables (which are globals in LLVM IR), subsequent patches use the same field. So this patch makes preliminary refactoring of the code tracking local entities to apply future functional changes lucidly and cleanly. No functional changes intended. Differential Revision: https://reviews.llvm.org/D143984
2023-06-07[Clang] Convert some tests to opaque pointers (NFC)Nikita Popov23-1009/+750
2023-06-06[Clang] Convert some tests to opaque pointers (NFC)Nikita Popov24-1860/+1469
2023-05-23[NFC][Py Reformat] Reformat python files in clang and clang-tools-extraTobias Hieta1-2/+2
This is an ongoing series of commits that are reformatting our Python code. Reformatting is done with `black`. If you end up having problems merging this commit because you have made changes to a python file, the best way to handle that is to run git checkout --ours <yourfile> and then reformat it with black. If you run into any problems, post to discourse about it and we will try to help. RFC Thread below: https://discourse.llvm.org/t/rfc-document-and-standardize-python-code-style Reviewed By: MatzeB Differential Revision: https://reviews.llvm.org/D150761
2023-02-17[Clang] Convert some tests to opaque pointers (NFC)Nikita Popov2-170/+119
2023-02-16[Clang] Convert some tests to opaque pointers (NFC)Nikita Popov4-100/+81
2023-01-26[Clang] Convert some tests to opaque pointers (NFC)Nikita Popov2-119/+94
These are all tests that end up running SROA.
2023-01-24[CodeGen] bugfix: add REQUIRES target triple in testusama hameed1-0/+1
2023-01-24[CodeGen] bugfix: ApplyDebugLocation goes out of scope before intendedusama hameed1-0/+14
rdar://103570533 Differential Revision: https://reviews.llvm.org/D142243
2023-01-05[CodeGen][ObjC] Fix a memory leak that occurs when a non-trivial CAkira Hatanaka1-0/+36
struct property is set using dot notation Make sure the destructor is called if needed. Differential Revision: https://reviews.llvm.org/D136639
2022-12-21[Clang][CGDebugInfo][ObjC] Mark objc bitfields with the DIFlagBitfield flagJuan Manuel MARTINEZ CAAMAÑO1-3/+3
Reviewed By: aprantl Differential Revision: https://reviews.llvm.org/D140195
2022-12-12[Clang] Try to fix test on Windows (NFC)Nikita Popov1-1/+1
Try to fix failure reported in https://reviews.llvm.org/rG9466b49171dc#1154213 by making the match more specific, as there are multiple dbg.declares that could be matched.
2022-12-12[Clang] Convert various tests to opaque pointers (NFC)Nikita Popov116-1195/+1071
These were all tests where no manual fixup was required.
2022-11-04[IR] Switch everything to use memory attributeNikita Popov1-1/+1
This switches everything to use the memory attribute proposed in https://discourse.llvm.org/t/rfc-unify-memory-effect-attributes/65579. The old argmemonly, inaccessiblememonly and inaccessiblemem_or_argmemonly attributes are dropped. The readnone, readonly and writeonly attributes are restricted to parameters only. The old attributes are auto-upgraded both in bitcode and IR. The bitcode upgrade is a policy requirement that has to be retained indefinitely. The IR upgrade is mainly there so it's not necessary to update all tests using memory attributes in this patch, which is already large enough. We could drop that part after migrating tests, or retain it longer term, to make it easier to import IR from older LLVM versions. High-level Function/CallBase APIs like doesNotAccessMemory() or setDoesNotAccessMemory() are mapped transparently to the memory attribute. Code that directly manipulates attributes (e.g. via AttributeList) on the other hand needs to switch to working with the memory attribute instead. Differential Revision: https://reviews.llvm.org/D135780
2022-10-14[CodeGen][ObjC] Call synthesized copy constructor/assignment operatorAkira Hatanaka1-0/+70
functions in getter/setter functions of non-trivial C struct properties This fixes a bug where the getter/setter functions were doing a trivial copy instead of calling the synthesized functions that copy non-trivial C struct types. This fixes https://github.com/llvm/llvm-project/issues/56680. Differential Revision: https://reviews.llvm.org/D131701
2022-10-11Fix assert in generated `direct` property getter/setters due to removal of ↵Michael Wyman1-0/+10
`_cmd` parameter. This fixes a bug from https://reviews.llvm.org/D131424 that removed the implicit `_cmd` parameter as an argument to `objc_direct` method implementations. In many cases the generated getter/setter will call `objc_getProperty` or `objc_setProperty`, both of which require the selector of the getter/setter; since `_cmd` didn't automatically have backing storage, attempting to load the address asserted. For direct property generated getters/setters, this now passes an undefined/uninitialized/poison value as the `_cmd` argument to `objc_getProperty`/`objc_setProperty`. Prior to removing the `_cmd` argument from the ABI of direct methods, it was left uninitialized/undefined; although references within hand-implemented methods would load the selector in the method prologue, generated getters/setters never did and just forwarded the undefined value that was passed as the argument. This change keeps the generated code mostly similar to before, passing an uninitialized/undefined/poison value; for setters, the value argument may be moved to another register. Added a test that triggers the assert prior to the implementation code. Differential Revision: https://reviews.llvm.org/D135091
2022-09-21Remove the unused/undefined `_cmd` parameter in `objc_direct` methods.Michael Wyman1-16/+21
When `objc_direct` methods were implemented, the implicit `_cmd` parameter was left as an argument to the method implementation function, but was unset by callers; if the method body referenced the `_cmd` variable, a selector load would be emitted inside the body. However, this leaves an unused argument in the ABI, and is unnecessary. This change removes the empty/unset argument, and if `_cmd` is referenced inside an `objc_direct` method it will emit local storage for the implicit variable. From the ABI perspective, `objc_direct` methods will have the implicit `self` parameter, immediately followed by whatever explicit arguments are defined on the method, rather than having one unset/undefined register in the middle. Differential Revision: https://reviews.llvm.org/D131424
2022-09-02[test] Change cc1 -fvisibility to -fvisibility=Fangrui Song6-8/+8
2022-07-24Fix crash in ObjC codegen introduced with ↵David Chisnall1-0/+22
5ab6ee75994d645725264e757d67bbb1c96fb2b6 5ab6ee75994d645725264e757d67bbb1c96fb2b6 assumed that if `RValue::isScalar()` returns true then `RValue::getScalarVal` will return a valid value. This is not the case when the return value is `void` and so void message returns would crash if they hit this path. This is triggered only for cases where the nil-handling path needs to do something non-trivial (destroy arguments that should be consumed by the callee). Reviewed By: triplef Differential Revision: https://reviews.llvm.org/D123898
2022-07-22Strengthen -Wint-conversion to default to an errorAaron Ballman1-1/+1
Clang has traditionally allowed C programs to implicitly convert integers to pointers and pointers to integers, despite it not being valid to do so except under special circumstances (like converting the integer 0, which is the null pointer constant, to a pointer). In C89, this would result in undefined behavior per 3.3.4, and in C99 this rule was strengthened to be a constraint violation instead. Constraint violations are most often handled as an error. This patch changes the warning to default to an error in all C modes (it is already an error in C++). This gives us better security posture by calling out potential programmer mistakes in code but still allows users who need this behavior to use -Wno-error=int-conversion to retain the warning behavior, or -Wno-int-conversion to silence the diagnostic entirely. Differential Revision: https://reviews.llvm.org/D129881
2022-07-18[clang] Introduce -fstrict-flex-arrays=<n> for stricter handling of flexible ↵serge-sans-paille1-43/+0
arrays Some code [0] consider that trailing arrays are flexible, whatever their size. Support for these legacy code has been introduced in f8f632498307d22e10fab0704548b270b15f1e1e but it prevents evaluation of __builtin_object_size and __builtin_dynamic_object_size in some legit cases. Introduce -fstrict-flex-arrays=<n> to have stricter conformance when it is desirable. n = 0: current behavior, any trailing array member is a flexible array. The default. n = 1: any trailing array member of undefined, 0 or 1 size is a flexible array member n = 2: any trailing array member of undefined or 0 size is a flexible array member This takes into account two specificities of clang: array bounds as macro id disqualify FAM, as well as non standard layout. Similar patch for gcc discuss here: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101836 [0] https://docs.freebsd.org/en/books/developers-handbook/sockets/#sockets-essential-functions
2022-07-05Revert "[SimplifyCFG] Thread branches on same condition in more cases (PR54980)"Nikita Popov1-8/+7
This reverts commit 4e545bdb355a470d601e9bb7f7b2693c99e61a3e. The newly added test is the third infinite combine loop caused by this change. In this case, it's a combination of the branch to common dest and jump threading folds that keeps peeling off loop iterations. The core problem here is that we ideally would not thread over loop backedges, both because it is potentially non-profitable (it may break canonical loop structure) and because it may result in these kinds of loops. Unfortunately, due to the lack of a dominator tree in SimplifyCFG, there is no good way to prevent this. While we have LoopHeaders, this is an optional structure and we don't do a good job of keeping it up to date. It would be fine for a profitability check, but is not suitable for a correctness check. So for now I'm just giving up here, as I don't see a good way to robustly prevent infinite combine loops. Fixes https://github.com/llvm/llvm-project/issues/56203.
2022-06-27Revert "[clang] Introduce -fstrict-flex-arrays=<n> for stricter handling of ↵Vitaly Buka1-0/+43
flexible arrays" This reverts D126864 and related fixes. This reverts commit 572b08790a69f955ae0cbb1b4a7d4a215f15dad9. This reverts commit 886715af962de2c92fac4bd37104450345711e4a.
2022-06-24[clang] Introduce -fstrict-flex-arrays=<n> for stricter handling of flexible ↵serge-sans-paille1-43/+0
arrays Some code [0] consider that trailing arrays are flexible, whatever their size. Support for these legacy code has been introduced in f8f632498307d22e10fab0704548b270b15f1e1e but it prevents evaluation of __builtin_object_size and __builtin_dynamic_object_size in some legit cases. Introduce -fstrict-flex-arrays=<n> to have stricter conformance when it is desirable. n = 0: current behavior, any trailing array member is a flexible array. The default. n = 1: any trailing array member of undefined, 0 or 1 size is a flexible array member n = 2: any trailing array member of undefined or 0 size is a flexible array member n = 3: any trailing array member of undefined size is a flexible array member (strict c99 conformance) Similar patch for gcc discuss here: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101836 [0] https://docs.freebsd.org/en/books/developers-handbook/sockets/#sockets-essential-functions
2022-06-17Stop wrapping GCCAsmStmts inside StmtExprs to destruct temporariesAkira Hatanaka1-0/+25
Instead, just pop the cleanups at the end of the asm statement. This fixes an assertion failure in BuildStmtExpr. It also fixes a bug where blocks and C compound literals were destructed at the end of the asm statement instead of at the end of the enclosing scope. Differential Revision: https://reviews.llvm.org/D125936
2022-05-26[FileCheck] Catch missspelled directives.Ivan Kosarev1-1/+1
Reviewed By: MaskRay Differential Revision: https://reviews.llvm.org/D125604
2022-04-29[SimplifyCFG] Thread branches on same condition in more cases (PR54980)Nikita Popov1-7/+8
SimplifyCFG implements basic jump threading, if a branch is performed on a phi node with constant operands. However, InstCombine canonicalizes such phis to the condition value of a previous branch, if possible. SimplifyCFG does support this as well, but only in the very limited case where the same condition is used in a direct predecessor -- notably, this does not include the common diamond pattern (i.e. two consecutive if/elses on the same condition). This patch extends the code to look back a limited number of blocks to find a branch on the same value, rather than only looking at the direct predecessor. Fixes https://github.com/llvm/llvm-project/issues/54980. Differential Revision: https://reviews.llvm.org/D124159
2022-04-20[C11/C2x] Change the behavior of the implicit function declaration warningAaron Ballman3-1/+5
C89 had a questionable feature where the compiler would implicitly declare a function that the user called but was never previously declared. The resulting function would be globally declared as extern int func(); -- a function without a prototype which accepts zero or more arguments. C99 removed support for this questionable feature due to severe security concerns. However, there was no deprecation period; C89 had the feature, C99 didn't. So Clang (and GCC) both supported the functionality as an extension in C99 and later modes. C2x no longer supports that function signature as it now requires all functions to have a prototype, and given the known security issues with the feature, continuing to support it as an extension is not tenable. This patch changes the diagnostic behavior for the -Wimplicit-function-declaration warning group depending on the language mode in effect. We continue to warn by default in C89 mode (due to the feature being dangerous to use). However, because this feature will not be supported in C2x mode, we've diagnosed it as being invalid for so long, the security concerns with the feature, and the trivial workaround for users (declare the function), we now default the extension warning to an error in C99-C17 mode. This still gives users an easy workaround if they are extensively using the extension in those modes (they can disable the warning or use -Wno-error to downgrade the error), but the new diagnostic makes it more clear that this feature is not supported and should be avoided. In C2x mode, we no longer allow an implicit function to be defined and treat the situation the same as any other lookup failure. Differential Revision: https://reviews.llvm.org/D122983
2022-04-11[CGCall] Check store type in findDominatingStoreToReturnValue()Nikita Popov1-1/+1
We need to make sure that the stored type matches the return type.
2022-04-07[Clang] Add -no-opaque-pointers to more tests (NFC)Nikita Popov1-2/+2
This adds the flag to more tests that were not caught by the mass-migration in 532dc62b907554b3f07f17205674aa71e76fc863.
2022-04-07[OpaquePtrs][Clang] Add -no-opaque-pointers to tests (NFC)Nikita Popov170-321/+321
This adds -no-opaque-pointers to clang tests whose output will change when opaque pointers are enabled by default. This is intended to be part of the migration approach described in https://discourse.llvm.org/t/enabling-opaque-pointers-by-default/61322/9. The patch has been produced by replacing %clang_cc1 with %clang_cc1 -no-opaque-pointers for tests that fail with opaque pointers enabled. Worth noting that this doesn't cover all tests, there's a remaining ~40 tests not using %clang_cc1 that will need a followup change. Differential Revision: https://reviews.llvm.org/D123115
2022-02-24Add -Wno-strict-prototypes to C tests; NFCAaron Ballman1-1/+1
This patch adds -Wno-strict-prototypes to all of the test cases that use functions without prototypes, but not as the primary concern of the test. e.g., attributes testing whether they can/cannot be applied to a function without a prototype, etc. This is done in preparation for enabling -Wstrict-prototypes by default.
2022-02-24Use functions with prototypes when appropriate; NFCAaron Ballman7-29/+29
A significant number of our tests in C accidentally use functions without prototypes. This patch converts the function signatures to have a prototype for the situations where the test is not specific to K&R C declarations. e.g., void func(); becomes void func(void); This is the final batch of tests being updated to add prototypes, hopefully.
2022-02-18[Clang] Rename `disable-noundef-analysis` flag to ↵hyeongyukim6-12/+12
`-[no-]enable-noundef-analysis` This flag was previously renamed `enable_noundef_analysis` to `disable-noundef-analysis,` which is not a conventional name. (Driver and CC1's boolean options are using [no-] prefix) As discussed at https://reviews.llvm.org/D105169, this patch reverts its name to `[no-]enable_noundef_analysis` and enables noundef-analysis as default. Reviewed By: MaskRay Differential Revision: https://reviews.llvm.org/D119998
2022-02-16Use functions with prototypes when appropriate; NFCAaron Ballman119-292/+292
A significant number of our tests in C accidentally use functions without prototypes. This patch converts the function signatures to have a prototype for the situations where the test is not specific to K&R C declarations. e.g., void func(); becomes void func(void); This is the twelfth batch of tests being updated (the end may be in sight soon though).
2022-01-28Do not crash when trying to encode a _BitInt typeAaron Ballman1-0/+21
Using a _BitInt (or _ExtInt) type as a block parameter or block return type hits an "unreachable" when trying to determine the encoding for the block. Instead of crashing, this patch handles it like some of the other types for which we don't yet have an encoding. The test case verifies we no longer crash, but does not verify that we provide any particular encoding (it can be updated once someone more familiar with ObjC steps in to define the encoding). Fixes PR50503.
2022-01-26[ObjC] Emit selector load right before msgSend call.Ahmed Bougacha17-99/+102
We currently emit the selector load early, but only because we need it to compute the signature (so that we know which msgSend variant to call). We can prepare the signature with a plain undef, and replace it with the materialized selector value if (and only if) needed, later. Concretely, this usually doesn't have an effect, but tests need updating because we reordered the receiver bitcast and the selector load, which is always fine. There is one notable change: with this, when a msgSend needs a receiver null check, the selector is now loaded in the non-null block, instead of before the null check. That should be a mild improvement.
2022-01-16[Clang/Test]: Rename enable_noundef_analysis to disable-noundef-analysis and ↵hyeongyu kim54-252/+240
turn it off by default Turning on `enable_noundef_analysis` flag allows better codegen by removing freeze instructions. I modified clang by renaming `enable_noundef_analysis` flag to `disable-noundef-analysis` and turning it off by default. Test updates are made as a separate patch: D108453 Reviewed By: eugenis Differential Revision: https://reviews.llvm.org/D105169
2022-01-11[CodeGen] Treat ObjC `__unsafe_unretained` and class types as trivialAkira Hatanaka2-0/+46
when generating copy/dispose helper functions Analyze the block captures just once before generating copy/dispose block helper functions and honor the inert `__unsafe_unretained` qualifier. This refactor fixes a bug where captures of ObjC `__unsafe_unretained` and class types were needlessly retained/released by the copy/dispose helper functions. Differential Revision: https://reviews.llvm.org/D116948
2022-01-06[CodeGen] Emit elementtype attributes for indirect inline asm constraintsNikita Popov2-3/+3
This implements the clang side of D116531. The elementtype attribute is added for all indirect constraints (*) and tests are updated accordingly. Differential Revision: https://reviews.llvm.org/D116666
2021-11-22[NFC][clang] Inclusive language: rename master variable to controller in ↵Quinn Pham1-3/+3
debug-info tests [NFC] As part of using inclusive language within the llvm project, this patch replaces master with controller in these tests. Reviewed By: rjmccall Differential Revision: https://reviews.llvm.org/D114108
2021-11-12[clang][objc][codegen] Skip emitting ObjC category metadata when theJosh Learn2-1/+20
category is empty Currently, if we create a category in ObjC that is empty, we still emit runtime metadata for that category. This is a scenario that could commonly be run into when using __attribute__((objc_direct_members)), which elides the need for much of the category metadata. This is slightly wasteful and can be easily skipped by checking the category metadata contents during CodeGen. rdar://66177182 Differential Revision: https://reviews.llvm.org/D113455