[flang-commits] [clang] [flang] [llvm] [Clang] Remove ARCMigrate (PR #119269)
via flang-commits
flang-commits at lists.llvm.org
Wed Jan 29 10:18:11 PST 2025
https://github.com/Sirraide updated https://github.com/llvm/llvm-project/pull/119269
>From 4a4aaf70dd4a4a7f55db9892244eb069c8bf9bcd Mon Sep 17 00:00:00 2001
From: Sirraide <aeternalmail at gmail.com>
Date: Fri, 17 Jan 2025 03:41:17 +0100
Subject: [PATCH 1/7] [Clang] Remove ARCMigrate
---
clang/include/clang/ARCMigrate/ARCMT.h | 130 -
clang/include/clang/ARCMigrate/ARCMTActions.h | 76 -
clang/include/clang/ARCMigrate/FileRemapper.h | 84 -
clang/lib/ARCMigrate/ARCMT.cpp | 616 -----
clang/lib/ARCMigrate/ARCMTActions.cpp | 59 -
clang/lib/ARCMigrate/CMakeLists.txt | 48 -
clang/lib/ARCMigrate/FileRemapper.cpp | 274 --
clang/lib/ARCMigrate/Internals.h | 180 --
clang/lib/ARCMigrate/ObjCMT.cpp | 2262 -----------------
clang/lib/ARCMigrate/PlistReporter.cpp | 124 -
clang/lib/ARCMigrate/TransAPIUses.cpp | 107 -
clang/lib/ARCMigrate/TransARCAssign.cpp | 77 -
clang/lib/ARCMigrate/TransAutoreleasePool.cpp | 435 ----
.../lib/ARCMigrate/TransBlockObjCVariable.cpp | 146 --
.../TransEmptyStatementsAndDealloc.cpp | 249 --
clang/lib/ARCMigrate/TransGCAttrs.cpp | 350 ---
clang/lib/ARCMigrate/TransGCCalls.cpp | 76 -
clang/lib/ARCMigrate/TransProperties.cpp | 379 ---
clang/lib/ARCMigrate/TransProtectedScope.cpp | 203 --
.../ARCMigrate/TransRetainReleaseDealloc.cpp | 459 ----
clang/lib/ARCMigrate/TransUnbridgedCasts.cpp | 466 ----
.../ARCMigrate/TransUnusedInitDelegate.cpp | 77 -
.../ARCMigrate/TransZeroOutPropsInDealloc.cpp | 224 --
clang/lib/ARCMigrate/TransformActions.cpp | 700 -----
clang/lib/ARCMigrate/Transforms.cpp | 594 -----
clang/lib/ARCMigrate/Transforms.h | 224 --
clang/test/ARCMT/Common.h | 110 -
clang/test/ARCMT/GC-check-warn-nsalloc.m | 10 -
clang/test/ARCMT/GC-check.m | 19 -
clang/test/ARCMT/GC-no-arc-runtime.m | 80 -
clang/test/ARCMT/GC-no-arc-runtime.m.result | 72 -
clang/test/ARCMT/GC-no-finalize-removal.m | 88 -
.../ARCMT/GC-no-finalize-removal.m.result | 96 -
clang/test/ARCMT/GC.h | 6 -
clang/test/ARCMT/GC.m | 93 -
clang/test/ARCMT/GC.m.result | 88 -
.../Headers/SubFramework.h | 5 -
.../Headers/Buried/Treasure.h | 1 -
.../Inputs/Module.framework/Headers/Module.h | 28 -
.../Module.framework/Headers/NotInModule.h | 1 -
.../Inputs/Module.framework/Headers/Sub.h | 3 -
.../Inputs/Module.framework/Headers/Sub2.h | 1 -
.../test/ARCMT/Inputs/Module.framework/Module | 0
.../PrivateHeaders/ModulePrivate.h | 1 -
clang/test/ARCMT/Inputs/module.modulemap | 309 ---
clang/test/ARCMT/Inputs/test.h | 15 -
clang/test/ARCMT/Inputs/test.h.result | 13 -
clang/test/ARCMT/Inputs/test1.m.in | 16 -
clang/test/ARCMT/Inputs/test1.m.in.result | 15 -
clang/test/ARCMT/Inputs/test2.m.in | 6 -
clang/test/ARCMT/Inputs/test2.m.in.result | 5 -
clang/test/ARCMT/Inputs/with space/test.h | 15 -
.../ARCMT/Inputs/with space/test.h.result | 13 -
clang/test/ARCMT/Inputs/with space/test1.m.in | 6 -
.../ARCMT/Inputs/with space/test1.m.in.result | 5 -
clang/test/ARCMT/Inputs/with space/test2.m.in | 6 -
.../ARCMT/Inputs/with space/test2.m.in.result | 5 -
clang/test/ARCMT/allowlisted/Inputs/header1.h | 1 -
clang/test/ARCMT/allowlisted/header1.h | 8 -
clang/test/ARCMT/allowlisted/header1.h.result | 7 -
clang/test/ARCMT/allowlisted/header2.h | 8 -
clang/test/ARCMT/allowlisted/header2.h.result | 7 -
.../allowlisted/objcmt-with-allowlist-impl.m | 18 -
.../objcmt-with-allowlist-impl.m.result | 18 -
.../ARCMT/allowlisted/objcmt-with-allowlist.m | 12 -
clang/test/ARCMT/api.m | 9 -
clang/test/ARCMT/api.m.result | 9 -
clang/test/ARCMT/assign-prop-no-arc-runtime.m | 15 -
.../ARCMT/assign-prop-no-arc-runtime.m.result | 15 -
.../test/ARCMT/assign-prop-with-arc-runtime.m | 72 -
.../assign-prop-with-arc-runtime.m.result | 72 -
clang/test/ARCMT/atautorelease-2.m | 29 -
clang/test/ARCMT/atautorelease-2.m.result | 28 -
clang/test/ARCMT/atautorelease-3.m | 40 -
clang/test/ARCMT/atautorelease-3.m.result | 31 -
clang/test/ARCMT/atautorelease-check.m | 144 --
clang/test/ARCMT/atautorelease.m | 61 -
clang/test/ARCMT/atautorelease.m.result | 60 -
clang/test/ARCMT/autoreleases.m | 75 -
clang/test/ARCMT/autoreleases.m.result | 69 -
clang/test/ARCMT/block_copy_release.m | 17 -
clang/test/ARCMT/block_copy_release.m.result | 15 -
clang/test/ARCMT/check-api.m | 43 -
clang/test/ARCMT/check-with-pch.m | 15 -
clang/test/ARCMT/check-with-serialized-diag.m | 55 -
clang/test/ARCMT/checking-in-arc.m | 50 -
clang/test/ARCMT/checking.m | 351 ---
clang/test/ARCMT/cxx-checking.mm | 100 -
clang/test/ARCMT/cxx-rewrite.mm | 33 -
clang/test/ARCMT/cxx-rewrite.mm.result | 31 -
clang/test/ARCMT/dealloc.m | 24 -
clang/test/ARCMT/dealloc.m.result | 20 -
.../designated-init-in-header.m | 3 -
.../designated-init-in-header/file1.m.in | 2 -
.../designated-init-in-header/file2.m.in | 14 -
.../file2.m.in.result | 14 -
.../ARCMT/designated-init-in-header/header1.h | 14 -
.../header1.h.result | 13 -
clang/test/ARCMT/dispatch.m | 18 -
clang/test/ARCMT/dispatch.m.result | 14 -
clang/test/ARCMT/driver-migrate.m | 15 -
clang/test/ARCMT/init.m | 39 -
clang/test/ARCMT/init.m.result | 39 -
clang/test/ARCMT/lit.local.cfg | 2 -
clang/test/ARCMT/migrate-emit-errors.m | 12 -
clang/test/ARCMT/migrate-on-pch-and-module.m | 12 -
clang/test/ARCMT/migrate-plist-output.m | 51 -
clang/test/ARCMT/migrate-space-in-path.m | 5 -
clang/test/ARCMT/migrate-with-pch.m | 6 -
clang/test/ARCMT/migrate.m | 5 -
.../no-canceling-bridge-to-bridge-cast.m | 41 -
clang/test/ARCMT/nonobjc-to-objc-cast-2.m | 63 -
clang/test/ARCMT/nonobjc-to-objc-cast.m | 83 -
.../test/ARCMT/nonobjc-to-objc-cast.m.result | 83 -
clang/test/ARCMT/objcmt-arc-cf-annotations.m | 2017 ---------------
.../ARCMT/objcmt-arc-cf-annotations.m.result | 2063 ---------------
clang/test/ARCMT/objcmt-atomic-property.m | 227 --
.../ARCMT/objcmt-atomic-property.m.result | 200 --
clang/test/ARCMT/objcmt-boxing.m | 106 -
clang/test/ARCMT/objcmt-boxing.m.result | 106 -
.../ARCMT/objcmt-designated-initializer.m | 44 -
.../objcmt-designated-initializer.m.result | 44 -
clang/test/ARCMT/objcmt-instancetype-2.m | 103 -
.../test/ARCMT/objcmt-instancetype-2.m.result | 103 -
.../objcmt-instancetype-unnecessary-diff.m | 10 -
clang/test/ARCMT/objcmt-instancetype.m | 111 -
clang/test/ARCMT/objcmt-instancetype.m.result | 111 -
clang/test/ARCMT/objcmt-invalid-code.mm | 19 -
.../test/ARCMT/objcmt-invalid-code.mm.result | 19 -
clang/test/ARCMT/objcmt-migrate-all.m | 133 -
clang/test/ARCMT/objcmt-migrate-all.m.result | 132 -
clang/test/ARCMT/objcmt-ns-enum-crash.m | 14 -
.../test/ARCMT/objcmt-ns-enum-crash.m.result | 14 -
clang/test/ARCMT/objcmt-ns-macros.m | 379 ---
clang/test/ARCMT/objcmt-ns-macros.m.result | 355 ---
.../test/ARCMT/objcmt-ns-nonatomic-iosonly.m | 233 --
.../objcmt-ns-nonatomic-iosonly.m.result | 206 --
.../ARCMT/objcmt-ns-returns-inner-pointer.m | 128 -
.../objcmt-ns-returns-inner-pointer.m.result | 128 -
clang/test/ARCMT/objcmt-numeric-literals.m | 502 ----
.../ARCMT/objcmt-numeric-literals.m.result | 502 ----
.../test/ARCMT/objcmt-property-availability.m | 45 -
.../objcmt-property-availability.m.result | 42 -
clang/test/ARCMT/objcmt-property-dot-syntax.m | 117 -
.../ARCMT/objcmt-property-dot-syntax.m.result | 117 -
clang/test/ARCMT/objcmt-property.m | 243 --
clang/test/ARCMT/objcmt-property.m.result | 215 --
.../test/ARCMT/objcmt-protocol-conformance.m | 129 -
.../objcmt-protocol-conformance.m.result | 129 -
.../objcmt-subscripting-literals-in-arc.m | 108 -
...jcmt-subscripting-literals-in-arc.m.result | 108 -
.../test/ARCMT/objcmt-subscripting-literals.m | 230 --
.../objcmt-subscripting-literals.m.result | 230 --
.../ARCMT/objcmt-subscripting-unavailable.m | 79 -
.../objcmt-subscripting-unavailable.m.result | 79 -
clang/test/ARCMT/objcmt-undefined-ns-macros.m | 22 -
.../ARCMT/objcmt-undefined-ns-macros.m.result | 24 -
clang/test/ARCMT/objcmt-with-pch.m | 17 -
clang/test/ARCMT/objcmt-with-pch.m.result | 17 -
clang/test/ARCMT/protected-scope.m | 36 -
clang/test/ARCMT/protected-scope.m.result | 38 -
clang/test/ARCMT/releases-driver.m | 67 -
clang/test/ARCMT/releases-driver.m.result | 58 -
clang/test/ARCMT/releases.m | 98 -
clang/test/ARCMT/releases.m.result | 87 -
clang/test/ARCMT/remap-applying.c | 4 -
clang/test/ARCMT/remap-applying.c.result | 4 -
clang/test/ARCMT/remove-dealloc-method.m | 26 -
.../test/ARCMT/remove-dealloc-method.m.result | 20 -
clang/test/ARCMT/remove-dealloc-zerouts.m | 44 -
.../ARCMT/remove-dealloc-zerouts.m.result | 39 -
clang/test/ARCMT/remove-statements.m | 45 -
clang/test/ARCMT/remove-statements.m.result | 38 -
clang/test/ARCMT/retains.m | 71 -
clang/test/ARCMT/retains.m.result | 65 -
clang/test/ARCMT/rewrite-block-var.m | 45 -
clang/test/ARCMT/rewrite-block-var.m.result | 45 -
clang/test/ARCMT/safe-arc-assign.m | 14 -
clang/test/ARCMT/safe-arc-assign.m.result | 14 -
clang/test/ARCMT/verify.m | 17 -
clang/test/ARCMT/with-arc-mode-modify.m | 13 -
.../test/ARCMT/with-arc-mode-modify.m.result | 12 -
182 files changed, 22720 deletions(-)
delete mode 100644 clang/include/clang/ARCMigrate/ARCMT.h
delete mode 100644 clang/include/clang/ARCMigrate/ARCMTActions.h
delete mode 100644 clang/include/clang/ARCMigrate/FileRemapper.h
delete mode 100644 clang/lib/ARCMigrate/ARCMT.cpp
delete mode 100644 clang/lib/ARCMigrate/ARCMTActions.cpp
delete mode 100644 clang/lib/ARCMigrate/CMakeLists.txt
delete mode 100644 clang/lib/ARCMigrate/FileRemapper.cpp
delete mode 100644 clang/lib/ARCMigrate/Internals.h
delete mode 100644 clang/lib/ARCMigrate/ObjCMT.cpp
delete mode 100644 clang/lib/ARCMigrate/PlistReporter.cpp
delete mode 100644 clang/lib/ARCMigrate/TransAPIUses.cpp
delete mode 100644 clang/lib/ARCMigrate/TransARCAssign.cpp
delete mode 100644 clang/lib/ARCMigrate/TransAutoreleasePool.cpp
delete mode 100644 clang/lib/ARCMigrate/TransBlockObjCVariable.cpp
delete mode 100644 clang/lib/ARCMigrate/TransEmptyStatementsAndDealloc.cpp
delete mode 100644 clang/lib/ARCMigrate/TransGCAttrs.cpp
delete mode 100644 clang/lib/ARCMigrate/TransGCCalls.cpp
delete mode 100644 clang/lib/ARCMigrate/TransProperties.cpp
delete mode 100644 clang/lib/ARCMigrate/TransProtectedScope.cpp
delete mode 100644 clang/lib/ARCMigrate/TransRetainReleaseDealloc.cpp
delete mode 100644 clang/lib/ARCMigrate/TransUnbridgedCasts.cpp
delete mode 100644 clang/lib/ARCMigrate/TransUnusedInitDelegate.cpp
delete mode 100644 clang/lib/ARCMigrate/TransZeroOutPropsInDealloc.cpp
delete mode 100644 clang/lib/ARCMigrate/TransformActions.cpp
delete mode 100644 clang/lib/ARCMigrate/Transforms.cpp
delete mode 100644 clang/lib/ARCMigrate/Transforms.h
delete mode 100644 clang/test/ARCMT/Common.h
delete mode 100644 clang/test/ARCMT/GC-check-warn-nsalloc.m
delete mode 100644 clang/test/ARCMT/GC-check.m
delete mode 100644 clang/test/ARCMT/GC-no-arc-runtime.m
delete mode 100644 clang/test/ARCMT/GC-no-arc-runtime.m.result
delete mode 100644 clang/test/ARCMT/GC-no-finalize-removal.m
delete mode 100644 clang/test/ARCMT/GC-no-finalize-removal.m.result
delete mode 100644 clang/test/ARCMT/GC.h
delete mode 100644 clang/test/ARCMT/GC.m
delete mode 100644 clang/test/ARCMT/GC.m.result
delete mode 100644 clang/test/ARCMT/Inputs/Module.framework/Frameworks/SubFramework.framework/Headers/SubFramework.h
delete mode 100644 clang/test/ARCMT/Inputs/Module.framework/Headers/Buried/Treasure.h
delete mode 100644 clang/test/ARCMT/Inputs/Module.framework/Headers/Module.h
delete mode 100644 clang/test/ARCMT/Inputs/Module.framework/Headers/NotInModule.h
delete mode 100644 clang/test/ARCMT/Inputs/Module.framework/Headers/Sub.h
delete mode 100644 clang/test/ARCMT/Inputs/Module.framework/Headers/Sub2.h
delete mode 100644 clang/test/ARCMT/Inputs/Module.framework/Module
delete mode 100644 clang/test/ARCMT/Inputs/Module.framework/PrivateHeaders/ModulePrivate.h
delete mode 100644 clang/test/ARCMT/Inputs/module.modulemap
delete mode 100644 clang/test/ARCMT/Inputs/test.h
delete mode 100644 clang/test/ARCMT/Inputs/test.h.result
delete mode 100644 clang/test/ARCMT/Inputs/test1.m.in
delete mode 100644 clang/test/ARCMT/Inputs/test1.m.in.result
delete mode 100644 clang/test/ARCMT/Inputs/test2.m.in
delete mode 100644 clang/test/ARCMT/Inputs/test2.m.in.result
delete mode 100644 clang/test/ARCMT/Inputs/with space/test.h
delete mode 100644 clang/test/ARCMT/Inputs/with space/test.h.result
delete mode 100644 clang/test/ARCMT/Inputs/with space/test1.m.in
delete mode 100644 clang/test/ARCMT/Inputs/with space/test1.m.in.result
delete mode 100644 clang/test/ARCMT/Inputs/with space/test2.m.in
delete mode 100644 clang/test/ARCMT/Inputs/with space/test2.m.in.result
delete mode 100644 clang/test/ARCMT/allowlisted/Inputs/header1.h
delete mode 100644 clang/test/ARCMT/allowlisted/header1.h
delete mode 100644 clang/test/ARCMT/allowlisted/header1.h.result
delete mode 100644 clang/test/ARCMT/allowlisted/header2.h
delete mode 100644 clang/test/ARCMT/allowlisted/header2.h.result
delete mode 100644 clang/test/ARCMT/allowlisted/objcmt-with-allowlist-impl.m
delete mode 100644 clang/test/ARCMT/allowlisted/objcmt-with-allowlist-impl.m.result
delete mode 100644 clang/test/ARCMT/allowlisted/objcmt-with-allowlist.m
delete mode 100644 clang/test/ARCMT/api.m
delete mode 100644 clang/test/ARCMT/api.m.result
delete mode 100644 clang/test/ARCMT/assign-prop-no-arc-runtime.m
delete mode 100644 clang/test/ARCMT/assign-prop-no-arc-runtime.m.result
delete mode 100644 clang/test/ARCMT/assign-prop-with-arc-runtime.m
delete mode 100644 clang/test/ARCMT/assign-prop-with-arc-runtime.m.result
delete mode 100644 clang/test/ARCMT/atautorelease-2.m
delete mode 100644 clang/test/ARCMT/atautorelease-2.m.result
delete mode 100644 clang/test/ARCMT/atautorelease-3.m
delete mode 100644 clang/test/ARCMT/atautorelease-3.m.result
delete mode 100644 clang/test/ARCMT/atautorelease-check.m
delete mode 100644 clang/test/ARCMT/atautorelease.m
delete mode 100644 clang/test/ARCMT/atautorelease.m.result
delete mode 100644 clang/test/ARCMT/autoreleases.m
delete mode 100644 clang/test/ARCMT/autoreleases.m.result
delete mode 100644 clang/test/ARCMT/block_copy_release.m
delete mode 100644 clang/test/ARCMT/block_copy_release.m.result
delete mode 100644 clang/test/ARCMT/check-api.m
delete mode 100644 clang/test/ARCMT/check-with-pch.m
delete mode 100644 clang/test/ARCMT/check-with-serialized-diag.m
delete mode 100644 clang/test/ARCMT/checking-in-arc.m
delete mode 100644 clang/test/ARCMT/checking.m
delete mode 100644 clang/test/ARCMT/cxx-checking.mm
delete mode 100644 clang/test/ARCMT/cxx-rewrite.mm
delete mode 100644 clang/test/ARCMT/cxx-rewrite.mm.result
delete mode 100644 clang/test/ARCMT/dealloc.m
delete mode 100644 clang/test/ARCMT/dealloc.m.result
delete mode 100644 clang/test/ARCMT/designated-init-in-header/designated-init-in-header.m
delete mode 100644 clang/test/ARCMT/designated-init-in-header/file1.m.in
delete mode 100644 clang/test/ARCMT/designated-init-in-header/file2.m.in
delete mode 100644 clang/test/ARCMT/designated-init-in-header/file2.m.in.result
delete mode 100644 clang/test/ARCMT/designated-init-in-header/header1.h
delete mode 100644 clang/test/ARCMT/designated-init-in-header/header1.h.result
delete mode 100644 clang/test/ARCMT/dispatch.m
delete mode 100644 clang/test/ARCMT/dispatch.m.result
delete mode 100644 clang/test/ARCMT/driver-migrate.m
delete mode 100644 clang/test/ARCMT/init.m
delete mode 100644 clang/test/ARCMT/init.m.result
delete mode 100644 clang/test/ARCMT/lit.local.cfg
delete mode 100644 clang/test/ARCMT/migrate-emit-errors.m
delete mode 100644 clang/test/ARCMT/migrate-on-pch-and-module.m
delete mode 100644 clang/test/ARCMT/migrate-plist-output.m
delete mode 100644 clang/test/ARCMT/migrate-space-in-path.m
delete mode 100644 clang/test/ARCMT/migrate-with-pch.m
delete mode 100644 clang/test/ARCMT/migrate.m
delete mode 100644 clang/test/ARCMT/no-canceling-bridge-to-bridge-cast.m
delete mode 100644 clang/test/ARCMT/nonobjc-to-objc-cast-2.m
delete mode 100644 clang/test/ARCMT/nonobjc-to-objc-cast.m
delete mode 100644 clang/test/ARCMT/nonobjc-to-objc-cast.m.result
delete mode 100644 clang/test/ARCMT/objcmt-arc-cf-annotations.m
delete mode 100644 clang/test/ARCMT/objcmt-arc-cf-annotations.m.result
delete mode 100644 clang/test/ARCMT/objcmt-atomic-property.m
delete mode 100644 clang/test/ARCMT/objcmt-atomic-property.m.result
delete mode 100644 clang/test/ARCMT/objcmt-boxing.m
delete mode 100644 clang/test/ARCMT/objcmt-boxing.m.result
delete mode 100644 clang/test/ARCMT/objcmt-designated-initializer.m
delete mode 100644 clang/test/ARCMT/objcmt-designated-initializer.m.result
delete mode 100644 clang/test/ARCMT/objcmt-instancetype-2.m
delete mode 100644 clang/test/ARCMT/objcmt-instancetype-2.m.result
delete mode 100644 clang/test/ARCMT/objcmt-instancetype-unnecessary-diff.m
delete mode 100644 clang/test/ARCMT/objcmt-instancetype.m
delete mode 100644 clang/test/ARCMT/objcmt-instancetype.m.result
delete mode 100644 clang/test/ARCMT/objcmt-invalid-code.mm
delete mode 100644 clang/test/ARCMT/objcmt-invalid-code.mm.result
delete mode 100644 clang/test/ARCMT/objcmt-migrate-all.m
delete mode 100644 clang/test/ARCMT/objcmt-migrate-all.m.result
delete mode 100644 clang/test/ARCMT/objcmt-ns-enum-crash.m
delete mode 100644 clang/test/ARCMT/objcmt-ns-enum-crash.m.result
delete mode 100644 clang/test/ARCMT/objcmt-ns-macros.m
delete mode 100644 clang/test/ARCMT/objcmt-ns-macros.m.result
delete mode 100644 clang/test/ARCMT/objcmt-ns-nonatomic-iosonly.m
delete mode 100644 clang/test/ARCMT/objcmt-ns-nonatomic-iosonly.m.result
delete mode 100644 clang/test/ARCMT/objcmt-ns-returns-inner-pointer.m
delete mode 100644 clang/test/ARCMT/objcmt-ns-returns-inner-pointer.m.result
delete mode 100644 clang/test/ARCMT/objcmt-numeric-literals.m
delete mode 100644 clang/test/ARCMT/objcmt-numeric-literals.m.result
delete mode 100644 clang/test/ARCMT/objcmt-property-availability.m
delete mode 100644 clang/test/ARCMT/objcmt-property-availability.m.result
delete mode 100644 clang/test/ARCMT/objcmt-property-dot-syntax.m
delete mode 100644 clang/test/ARCMT/objcmt-property-dot-syntax.m.result
delete mode 100644 clang/test/ARCMT/objcmt-property.m
delete mode 100644 clang/test/ARCMT/objcmt-property.m.result
delete mode 100644 clang/test/ARCMT/objcmt-protocol-conformance.m
delete mode 100644 clang/test/ARCMT/objcmt-protocol-conformance.m.result
delete mode 100644 clang/test/ARCMT/objcmt-subscripting-literals-in-arc.m
delete mode 100644 clang/test/ARCMT/objcmt-subscripting-literals-in-arc.m.result
delete mode 100644 clang/test/ARCMT/objcmt-subscripting-literals.m
delete mode 100644 clang/test/ARCMT/objcmt-subscripting-literals.m.result
delete mode 100644 clang/test/ARCMT/objcmt-subscripting-unavailable.m
delete mode 100644 clang/test/ARCMT/objcmt-subscripting-unavailable.m.result
delete mode 100644 clang/test/ARCMT/objcmt-undefined-ns-macros.m
delete mode 100644 clang/test/ARCMT/objcmt-undefined-ns-macros.m.result
delete mode 100644 clang/test/ARCMT/objcmt-with-pch.m
delete mode 100644 clang/test/ARCMT/objcmt-with-pch.m.result
delete mode 100644 clang/test/ARCMT/protected-scope.m
delete mode 100644 clang/test/ARCMT/protected-scope.m.result
delete mode 100644 clang/test/ARCMT/releases-driver.m
delete mode 100644 clang/test/ARCMT/releases-driver.m.result
delete mode 100644 clang/test/ARCMT/releases.m
delete mode 100644 clang/test/ARCMT/releases.m.result
delete mode 100644 clang/test/ARCMT/remap-applying.c
delete mode 100644 clang/test/ARCMT/remap-applying.c.result
delete mode 100644 clang/test/ARCMT/remove-dealloc-method.m
delete mode 100644 clang/test/ARCMT/remove-dealloc-method.m.result
delete mode 100644 clang/test/ARCMT/remove-dealloc-zerouts.m
delete mode 100644 clang/test/ARCMT/remove-dealloc-zerouts.m.result
delete mode 100644 clang/test/ARCMT/remove-statements.m
delete mode 100644 clang/test/ARCMT/remove-statements.m.result
delete mode 100644 clang/test/ARCMT/retains.m
delete mode 100644 clang/test/ARCMT/retains.m.result
delete mode 100644 clang/test/ARCMT/rewrite-block-var.m
delete mode 100644 clang/test/ARCMT/rewrite-block-var.m.result
delete mode 100644 clang/test/ARCMT/safe-arc-assign.m
delete mode 100644 clang/test/ARCMT/safe-arc-assign.m.result
delete mode 100644 clang/test/ARCMT/verify.m
delete mode 100644 clang/test/ARCMT/with-arc-mode-modify.m
delete mode 100644 clang/test/ARCMT/with-arc-mode-modify.m.result
diff --git a/clang/include/clang/ARCMigrate/ARCMT.h b/clang/include/clang/ARCMigrate/ARCMT.h
deleted file mode 100644
index 2b950e3d2cc2bf..00000000000000
--- a/clang/include/clang/ARCMigrate/ARCMT.h
+++ /dev/null
@@ -1,130 +0,0 @@
-//===-- ARCMT.h - ARC Migration Rewriter ------------------------*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_CLANG_ARCMIGRATE_ARCMT_H
-#define LLVM_CLANG_ARCMIGRATE_ARCMT_H
-
-#include "clang/ARCMigrate/FileRemapper.h"
-#include "clang/Basic/SourceLocation.h"
-#include "clang/Frontend/CompilerInvocation.h"
-
-namespace clang {
- class ASTContext;
- class DiagnosticConsumer;
- class PCHContainerOperations;
-
-namespace arcmt {
- class MigrationPass;
-
-/// Creates an AST with the provided CompilerInvocation but with these
-/// changes:
-/// -if a PCH/PTH is set, the original header is used instead
-/// -Automatic Reference Counting mode is enabled
-///
-/// It then checks the AST and produces errors/warning for ARC migration issues
-/// that the user needs to handle manually.
-///
-/// \param emitPremigrationARCErrors if true all ARC errors will get emitted
-/// even if the migrator can fix them, but the function will still return false
-/// if all ARC errors can be fixed.
-///
-/// \param plistOut if non-empty, it is the file path to store the plist with
-/// the pre-migration ARC diagnostics.
-///
-/// \returns false if no error is produced, true otherwise.
-bool
-checkForManualIssues(CompilerInvocation &CI, const FrontendInputFile &Input,
- std::shared_ptr<PCHContainerOperations> PCHContainerOps,
- DiagnosticConsumer *DiagClient,
- bool emitPremigrationARCErrors = false,
- StringRef plistOut = StringRef());
-
-/// Works similar to checkForManualIssues but instead of checking, it
-/// applies automatic modifications to source files to conform to ARC.
-///
-/// \returns false if no error is produced, true otherwise.
-bool
-applyTransformations(CompilerInvocation &origCI,
- const FrontendInputFile &Input,
- std::shared_ptr<PCHContainerOperations> PCHContainerOps,
- DiagnosticConsumer *DiagClient);
-
-/// Applies automatic modifications and produces temporary files
-/// and metadata into the \p outputDir path.
-///
-/// \param emitPremigrationARCErrors if true all ARC errors will get emitted
-/// even if the migrator can fix them, but the function will still return false
-/// if all ARC errors can be fixed.
-///
-/// \param plistOut if non-empty, it is the file path to store the plist with
-/// the pre-migration ARC diagnostics.
-///
-/// \returns false if no error is produced, true otherwise.
-bool migrateWithTemporaryFiles(
- CompilerInvocation &origCI, const FrontendInputFile &Input,
- std::shared_ptr<PCHContainerOperations> PCHContainerOps,
- DiagnosticConsumer *DiagClient, StringRef outputDir,
- bool emitPremigrationARCErrors, StringRef plistOut);
-
-/// Get the set of file remappings from the \p outputDir path that
-/// migrateWithTemporaryFiles produced.
-///
-/// \returns false if no error is produced, true otherwise.
-bool getFileRemappings(std::vector<std::pair<std::string,std::string> > &remap,
- StringRef outputDir,
- DiagnosticConsumer *DiagClient);
-
-/// Get the set of file remappings from a list of files with remapping
-/// info.
-///
-/// \returns false if no error is produced, true otherwise.
-bool getFileRemappingsFromFileList(
- std::vector<std::pair<std::string,std::string> > &remap,
- ArrayRef<StringRef> remapFiles,
- DiagnosticConsumer *DiagClient);
-
-typedef void (*TransformFn)(MigrationPass &pass);
-
-std::vector<TransformFn> getAllTransformations(LangOptions::GCMode OrigGCMode,
- bool NoFinalizeRemoval);
-
-class MigrationProcess {
- CompilerInvocation OrigCI;
- std::shared_ptr<PCHContainerOperations> PCHContainerOps;
- DiagnosticConsumer *DiagClient;
- FileRemapper Remapper;
-
-public:
- bool HadARCErrors;
-
- MigrationProcess(CompilerInvocation &CI,
- std::shared_ptr<PCHContainerOperations> PCHContainerOps,
- DiagnosticConsumer *diagClient,
- StringRef outputDir = StringRef());
-
- class RewriteListener {
- public:
- virtual ~RewriteListener();
-
- virtual void start(ASTContext &Ctx) { }
- virtual void finish() { }
-
- virtual void insert(SourceLocation loc, StringRef text) { }
- virtual void remove(CharSourceRange range) { }
- };
-
- bool applyTransform(TransformFn trans, RewriteListener *listener = nullptr);
-
- FileRemapper &getRemapper() { return Remapper; }
-};
-
-} // end namespace arcmt
-
-} // end namespace clang
-
-#endif
diff --git a/clang/include/clang/ARCMigrate/ARCMTActions.h b/clang/include/clang/ARCMigrate/ARCMTActions.h
deleted file mode 100644
index 714f4b33db446b..00000000000000
--- a/clang/include/clang/ARCMigrate/ARCMTActions.h
+++ /dev/null
@@ -1,76 +0,0 @@
-//===--- ARCMTActions.h - ARC Migrate Tool Frontend Actions -----*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_CLANG_ARCMIGRATE_ARCMTACTIONS_H
-#define LLVM_CLANG_ARCMIGRATE_ARCMTACTIONS_H
-
-#include "clang/ARCMigrate/FileRemapper.h"
-#include "clang/Frontend/FrontendAction.h"
-#include <memory>
-
-namespace clang {
-namespace arcmt {
-
-class CheckAction : public WrapperFrontendAction {
-protected:
- bool BeginInvocation(CompilerInstance &CI) override;
-
-public:
- CheckAction(std::unique_ptr<FrontendAction> WrappedAction);
-};
-
-class ModifyAction : public WrapperFrontendAction {
-protected:
- bool BeginInvocation(CompilerInstance &CI) override;
-
-public:
- ModifyAction(std::unique_ptr<FrontendAction> WrappedAction);
-};
-
-class MigrateSourceAction : public ASTFrontendAction {
- FileRemapper Remapper;
-protected:
- bool BeginInvocation(CompilerInstance &CI) override;
- std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI,
- StringRef InFile) override;
-};
-
-class MigrateAction : public WrapperFrontendAction {
- std::string MigrateDir;
- std::string PlistOut;
- bool EmitPremigrationARCErrors;
-protected:
- bool BeginInvocation(CompilerInstance &CI) override;
-
-public:
- MigrateAction(std::unique_ptr<FrontendAction> WrappedAction,
- StringRef migrateDir,
- StringRef plistOut,
- bool emitPremigrationARCErrors);
-};
-
-/// Migrates to modern ObjC syntax.
-class ObjCMigrateAction : public WrapperFrontendAction {
- std::string MigrateDir;
- unsigned ObjCMigAction;
- FileRemapper Remapper;
- CompilerInstance *CompInst;
-public:
- ObjCMigrateAction(std::unique_ptr<FrontendAction> WrappedAction,
- StringRef migrateDir, unsigned migrateAction);
-
-protected:
- std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI,
- StringRef InFile) override;
- bool BeginInvocation(CompilerInstance &CI) override;
-};
-
-}
-}
-
-#endif
diff --git a/clang/include/clang/ARCMigrate/FileRemapper.h b/clang/include/clang/ARCMigrate/FileRemapper.h
deleted file mode 100644
index afcee363516a21..00000000000000
--- a/clang/include/clang/ARCMigrate/FileRemapper.h
+++ /dev/null
@@ -1,84 +0,0 @@
-//===-- FileRemapper.h - File Remapping Helper ------------------*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_CLANG_ARCMIGRATE_FILEREMAPPER_H
-#define LLVM_CLANG_ARCMIGRATE_FILEREMAPPER_H
-
-#include "clang/Basic/FileEntry.h"
-#include "clang/Basic/LLVM.h"
-#include "llvm/ADT/DenseMap.h"
-#include "llvm/ADT/STLExtras.h"
-#include "llvm/ADT/StringRef.h"
-#include <memory>
-#include <variant>
-
-namespace llvm {
- class MemoryBuffer;
- class MemoryBufferRef;
-}
-
-namespace clang {
- class FileManager;
- class DiagnosticsEngine;
- class PreprocessorOptions;
-
-namespace arcmt {
-
-class FileRemapper {
- // FIXME: Reuse the same FileManager for multiple ASTContexts.
- std::unique_ptr<FileManager> FileMgr;
-
- using Target = std::variant<FileEntryRef, llvm::MemoryBuffer *>;
- using MappingsTy = llvm::DenseMap<FileEntryRef, Target>;
- MappingsTy FromToMappings;
-
- llvm::DenseMap<const FileEntry *, FileEntryRef> ToFromMappings;
-
-public:
- FileRemapper();
- ~FileRemapper();
-
- bool initFromDisk(StringRef outputDir, DiagnosticsEngine &Diag,
- bool ignoreIfFilesChanged);
- bool initFromFile(StringRef filePath, DiagnosticsEngine &Diag,
- bool ignoreIfFilesChanged);
- bool flushToDisk(StringRef outputDir, DiagnosticsEngine &Diag);
- bool flushToFile(StringRef outputPath, DiagnosticsEngine &Diag);
-
- bool overwriteOriginal(DiagnosticsEngine &Diag,
- StringRef outputDir = StringRef());
-
- void remap(StringRef filePath, std::unique_ptr<llvm::MemoryBuffer> memBuf);
-
- void applyMappings(PreprocessorOptions &PPOpts) const;
-
- /// Iterate through all the mappings.
- void forEachMapping(
- llvm::function_ref<void(StringRef, StringRef)> CaptureFile,
- llvm::function_ref<void(StringRef, const llvm::MemoryBufferRef &)>
- CaptureBuffer) const;
-
- void clear(StringRef outputDir = StringRef());
-
-private:
- void remap(FileEntryRef file, std::unique_ptr<llvm::MemoryBuffer> memBuf);
- void remap(FileEntryRef file, FileEntryRef newfile);
-
- OptionalFileEntryRef getOriginalFile(StringRef filePath);
- void resetTarget(Target &targ);
-
- bool report(const Twine &err, DiagnosticsEngine &Diag);
-
- std::string getRemapInfoFile(StringRef outputDir);
-};
-
-} // end namespace arcmt
-
-} // end namespace clang
-
-#endif
diff --git a/clang/lib/ARCMigrate/ARCMT.cpp b/clang/lib/ARCMigrate/ARCMT.cpp
deleted file mode 100644
index 1a8a200f2fc194..00000000000000
--- a/clang/lib/ARCMigrate/ARCMT.cpp
+++ /dev/null
@@ -1,616 +0,0 @@
-//===--- ARCMT.cpp - Migration to ARC mode --------------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#include "clang/ARCMigrate/ARCMT.h"
-#include "Internals.h"
-#include "clang/AST/ASTConsumer.h"
-#include "clang/Basic/DiagnosticCategories.h"
-#include "clang/Frontend/ASTUnit.h"
-#include "clang/Frontend/CompilerInstance.h"
-#include "clang/Frontend/FrontendAction.h"
-#include "clang/Frontend/TextDiagnosticPrinter.h"
-#include "clang/Frontend/Utils.h"
-#include "clang/Lex/Preprocessor.h"
-#include "clang/Lex/PreprocessorOptions.h"
-#include "clang/Rewrite/Core/Rewriter.h"
-#include "clang/Sema/SemaDiagnostic.h"
-#include "clang/Serialization/ASTReader.h"
-#include "llvm/Support/MemoryBuffer.h"
-#include "llvm/TargetParser/Triple.h"
-#include <utility>
-using namespace clang;
-using namespace arcmt;
-
-bool CapturedDiagList::clearDiagnostic(ArrayRef<unsigned> IDs,
- SourceRange range) {
- if (range.isInvalid())
- return false;
-
- bool cleared = false;
- ListTy::iterator I = List.begin();
- while (I != List.end()) {
- FullSourceLoc diagLoc = I->getLocation();
- if ((IDs.empty() || // empty means clear all diagnostics in the range.
- llvm::is_contained(IDs, I->getID())) &&
- !diagLoc.isBeforeInTranslationUnitThan(range.getBegin()) &&
- (diagLoc == range.getEnd() ||
- diagLoc.isBeforeInTranslationUnitThan(range.getEnd()))) {
- cleared = true;
- ListTy::iterator eraseS = I++;
- if (eraseS->getLevel() != DiagnosticsEngine::Note)
- while (I != List.end() && I->getLevel() == DiagnosticsEngine::Note)
- ++I;
- // Clear the diagnostic and any notes following it.
- I = List.erase(eraseS, I);
- continue;
- }
-
- ++I;
- }
-
- return cleared;
-}
-
-bool CapturedDiagList::hasDiagnostic(ArrayRef<unsigned> IDs,
- SourceRange range) const {
- if (range.isInvalid())
- return false;
-
- ListTy::const_iterator I = List.begin();
- while (I != List.end()) {
- FullSourceLoc diagLoc = I->getLocation();
- if ((IDs.empty() || // empty means any diagnostic in the range.
- llvm::is_contained(IDs, I->getID())) &&
- !diagLoc.isBeforeInTranslationUnitThan(range.getBegin()) &&
- (diagLoc == range.getEnd() ||
- diagLoc.isBeforeInTranslationUnitThan(range.getEnd()))) {
- return true;
- }
-
- ++I;
- }
-
- return false;
-}
-
-void CapturedDiagList::reportDiagnostics(DiagnosticsEngine &Diags) const {
- for (ListTy::const_iterator I = List.begin(), E = List.end(); I != E; ++I)
- Diags.Report(*I);
-}
-
-bool CapturedDiagList::hasErrors() const {
- for (ListTy::const_iterator I = List.begin(), E = List.end(); I != E; ++I)
- if (I->getLevel() >= DiagnosticsEngine::Error)
- return true;
-
- return false;
-}
-
-namespace {
-
-class CaptureDiagnosticConsumer : public DiagnosticConsumer {
- DiagnosticsEngine &Diags;
- DiagnosticConsumer &DiagClient;
- CapturedDiagList &CapturedDiags;
- bool HasBegunSourceFile;
-public:
- CaptureDiagnosticConsumer(DiagnosticsEngine &diags,
- DiagnosticConsumer &client,
- CapturedDiagList &capturedDiags)
- : Diags(diags), DiagClient(client), CapturedDiags(capturedDiags),
- HasBegunSourceFile(false) { }
-
- void BeginSourceFile(const LangOptions &Opts,
- const Preprocessor *PP) override {
- // Pass BeginSourceFile message onto DiagClient on first call.
- // The corresponding EndSourceFile call will be made from an
- // explicit call to FinishCapture.
- if (!HasBegunSourceFile) {
- DiagClient.BeginSourceFile(Opts, PP);
- HasBegunSourceFile = true;
- }
- }
-
- void FinishCapture() {
- // Call EndSourceFile on DiagClient on completion of capture to
- // enable VerifyDiagnosticConsumer to check diagnostics *after*
- // it has received the diagnostic list.
- if (HasBegunSourceFile) {
- DiagClient.EndSourceFile();
- HasBegunSourceFile = false;
- }
- }
-
- ~CaptureDiagnosticConsumer() override {
- assert(!HasBegunSourceFile && "FinishCapture not called!");
- }
-
- void HandleDiagnostic(DiagnosticsEngine::Level level,
- const Diagnostic &Info) override {
- if (DiagnosticIDs::isARCDiagnostic(Info.getID()) ||
- level >= DiagnosticsEngine::Error || level == DiagnosticsEngine::Note) {
- if (Info.getLocation().isValid())
- CapturedDiags.push_back(StoredDiagnostic(level, Info));
- return;
- }
-
- // Non-ARC warnings are ignored.
- Diags.setLastDiagnosticIgnored(true);
- }
-};
-
-} // end anonymous namespace
-
-static bool HasARCRuntime(CompilerInvocation &origCI) {
- // This duplicates some functionality from Darwin::AddDeploymentTarget
- // but this function is well defined, so keep it decoupled from the driver
- // and avoid unrelated complications.
- llvm::Triple triple(origCI.getTargetOpts().Triple);
-
- if (triple.isiOS())
- return triple.getOSMajorVersion() >= 5;
-
- if (triple.isWatchOS())
- return true;
-
- if (triple.getOS() == llvm::Triple::Darwin)
- return triple.getOSMajorVersion() >= 11;
-
- if (triple.getOS() == llvm::Triple::MacOSX) {
- return triple.getOSVersion() >= VersionTuple(10, 7);
- }
-
- return false;
-}
-
-static CompilerInvocation *
-createInvocationForMigration(CompilerInvocation &origCI,
- const PCHContainerReader &PCHContainerRdr) {
- std::unique_ptr<CompilerInvocation> CInvok;
- CInvok.reset(new CompilerInvocation(origCI));
- PreprocessorOptions &PPOpts = CInvok->getPreprocessorOpts();
- if (!PPOpts.ImplicitPCHInclude.empty()) {
- // We can't use a PCH because it was likely built in non-ARC mode and we
- // want to parse in ARC. Include the original header.
- FileManager FileMgr(origCI.getFileSystemOpts());
- IntrusiveRefCntPtr<DiagnosticIDs> DiagID(new DiagnosticIDs());
- IntrusiveRefCntPtr<DiagnosticsEngine> Diags(
- new DiagnosticsEngine(DiagID, &origCI.getDiagnosticOpts(),
- new IgnoringDiagConsumer()));
- std::string OriginalFile = ASTReader::getOriginalSourceFile(
- PPOpts.ImplicitPCHInclude, FileMgr, PCHContainerRdr, *Diags);
- if (!OriginalFile.empty())
- PPOpts.Includes.insert(PPOpts.Includes.begin(), OriginalFile);
- PPOpts.ImplicitPCHInclude.clear();
- }
- std::string define = std::string(getARCMTMacroName());
- define += '=';
- CInvok->getPreprocessorOpts().addMacroDef(define);
- CInvok->getLangOpts().ObjCAutoRefCount = true;
- CInvok->getLangOpts().setGC(LangOptions::NonGC);
- CInvok->getDiagnosticOpts().ErrorLimit = 0;
- CInvok->getDiagnosticOpts().PedanticErrors = 0;
-
- // Ignore -Werror flags when migrating.
- std::vector<std::string> WarnOpts;
- for (std::vector<std::string>::iterator
- I = CInvok->getDiagnosticOpts().Warnings.begin(),
- E = CInvok->getDiagnosticOpts().Warnings.end(); I != E; ++I) {
- if (!StringRef(*I).starts_with("error"))
- WarnOpts.push_back(*I);
- }
- WarnOpts.push_back("error=arc-unsafe-retained-assign");
- CInvok->getDiagnosticOpts().Warnings = std::move(WarnOpts);
-
- CInvok->getLangOpts().ObjCWeakRuntime = HasARCRuntime(origCI);
- CInvok->getLangOpts().ObjCWeak = CInvok->getLangOpts().ObjCWeakRuntime;
-
- return CInvok.release();
-}
-
-static void emitPremigrationErrors(const CapturedDiagList &arcDiags,
- DiagnosticOptions *diagOpts,
- Preprocessor &PP) {
- TextDiagnosticPrinter printer(llvm::errs(), diagOpts);
- IntrusiveRefCntPtr<DiagnosticIDs> DiagID(new DiagnosticIDs());
- IntrusiveRefCntPtr<DiagnosticsEngine> Diags(
- new DiagnosticsEngine(DiagID, diagOpts, &printer,
- /*ShouldOwnClient=*/false));
- Diags->setSourceManager(&PP.getSourceManager());
-
- printer.BeginSourceFile(PP.getLangOpts(), &PP);
- arcDiags.reportDiagnostics(*Diags);
- printer.EndSourceFile();
-}
-
-//===----------------------------------------------------------------------===//
-// checkForManualIssues.
-//===----------------------------------------------------------------------===//
-
-bool arcmt::checkForManualIssues(
- CompilerInvocation &origCI, const FrontendInputFile &Input,
- std::shared_ptr<PCHContainerOperations> PCHContainerOps,
- DiagnosticConsumer *DiagClient, bool emitPremigrationARCErrors,
- StringRef plistOut) {
- if (!origCI.getLangOpts().ObjC)
- return false;
-
- LangOptions::GCMode OrigGCMode = origCI.getLangOpts().getGC();
- bool NoNSAllocReallocError = origCI.getMigratorOpts().NoNSAllocReallocError;
- bool NoFinalizeRemoval = origCI.getMigratorOpts().NoFinalizeRemoval;
-
- std::vector<TransformFn> transforms = arcmt::getAllTransformations(OrigGCMode,
- NoFinalizeRemoval);
- assert(!transforms.empty());
-
- std::unique_ptr<CompilerInvocation> CInvok;
- CInvok.reset(
- createInvocationForMigration(origCI, PCHContainerOps->getRawReader()));
- CInvok->getFrontendOpts().Inputs.clear();
- CInvok->getFrontendOpts().Inputs.push_back(Input);
-
- CapturedDiagList capturedDiags;
-
- assert(DiagClient);
- IntrusiveRefCntPtr<DiagnosticIDs> DiagID(new DiagnosticIDs());
- IntrusiveRefCntPtr<DiagnosticsEngine> Diags(
- new DiagnosticsEngine(DiagID, &origCI.getDiagnosticOpts(),
- DiagClient, /*ShouldOwnClient=*/false));
-
- // Filter of all diagnostics.
- CaptureDiagnosticConsumer errRec(*Diags, *DiagClient, capturedDiags);
- Diags->setClient(&errRec, /*ShouldOwnClient=*/false);
-
- std::unique_ptr<ASTUnit> Unit(ASTUnit::LoadFromCompilerInvocationAction(
- std::move(CInvok), PCHContainerOps, Diags));
- if (!Unit) {
- errRec.FinishCapture();
- return true;
- }
-
- // Don't filter diagnostics anymore.
- Diags->setClient(DiagClient, /*ShouldOwnClient=*/false);
-
- ASTContext &Ctx = Unit->getASTContext();
-
- if (Diags->hasFatalErrorOccurred()) {
- Diags->Reset();
- DiagClient->BeginSourceFile(Ctx.getLangOpts(), &Unit->getPreprocessor());
- capturedDiags.reportDiagnostics(*Diags);
- DiagClient->EndSourceFile();
- errRec.FinishCapture();
- return true;
- }
-
- if (emitPremigrationARCErrors)
- emitPremigrationErrors(capturedDiags, &origCI.getDiagnosticOpts(),
- Unit->getPreprocessor());
- if (!plistOut.empty()) {
- SmallVector<StoredDiagnostic, 8> arcDiags;
- for (CapturedDiagList::iterator
- I = capturedDiags.begin(), E = capturedDiags.end(); I != E; ++I)
- arcDiags.push_back(*I);
- writeARCDiagsToPlist(std::string(plistOut), arcDiags,
- Ctx.getSourceManager(), Ctx.getLangOpts());
- }
-
- // After parsing of source files ended, we want to reuse the
- // diagnostics objects to emit further diagnostics.
- // We call BeginSourceFile because DiagnosticConsumer requires that
- // diagnostics with source range information are emitted only in between
- // BeginSourceFile() and EndSourceFile().
- DiagClient->BeginSourceFile(Ctx.getLangOpts(), &Unit->getPreprocessor());
-
- // No macros will be added since we are just checking and we won't modify
- // source code.
- std::vector<SourceLocation> ARCMTMacroLocs;
-
- TransformActions testAct(*Diags, capturedDiags, Ctx, Unit->getPreprocessor());
- MigrationPass pass(Ctx, OrigGCMode, Unit->getSema(), testAct, capturedDiags,
- ARCMTMacroLocs);
- pass.setNoFinalizeRemoval(NoFinalizeRemoval);
- if (!NoNSAllocReallocError)
- Diags->setSeverity(diag::warn_arcmt_nsalloc_realloc, diag::Severity::Error,
- SourceLocation());
-
- for (unsigned i=0, e = transforms.size(); i != e; ++i)
- transforms[i](pass);
-
- capturedDiags.reportDiagnostics(*Diags);
-
- DiagClient->EndSourceFile();
- errRec.FinishCapture();
-
- return capturedDiags.hasErrors() || testAct.hasReportedErrors();
-}
-
-//===----------------------------------------------------------------------===//
-// applyTransformations.
-//===----------------------------------------------------------------------===//
-
-static bool
-applyTransforms(CompilerInvocation &origCI, const FrontendInputFile &Input,
- std::shared_ptr<PCHContainerOperations> PCHContainerOps,
- DiagnosticConsumer *DiagClient, StringRef outputDir,
- bool emitPremigrationARCErrors, StringRef plistOut) {
- if (!origCI.getLangOpts().ObjC)
- return false;
-
- LangOptions::GCMode OrigGCMode = origCI.getLangOpts().getGC();
-
- // Make sure checking is successful first.
- CompilerInvocation CInvokForCheck(origCI);
- if (arcmt::checkForManualIssues(CInvokForCheck, Input, PCHContainerOps,
- DiagClient, emitPremigrationARCErrors,
- plistOut))
- return true;
-
- CompilerInvocation CInvok(origCI);
- CInvok.getFrontendOpts().Inputs.clear();
- CInvok.getFrontendOpts().Inputs.push_back(Input);
-
- MigrationProcess migration(CInvok, PCHContainerOps, DiagClient, outputDir);
- bool NoFinalizeRemoval = origCI.getMigratorOpts().NoFinalizeRemoval;
-
- std::vector<TransformFn> transforms = arcmt::getAllTransformations(OrigGCMode,
- NoFinalizeRemoval);
- assert(!transforms.empty());
-
- for (unsigned i=0, e = transforms.size(); i != e; ++i) {
- bool err = migration.applyTransform(transforms[i]);
- if (err) return true;
- }
-
- IntrusiveRefCntPtr<DiagnosticIDs> DiagID(new DiagnosticIDs());
- IntrusiveRefCntPtr<DiagnosticsEngine> Diags(
- new DiagnosticsEngine(DiagID, &origCI.getDiagnosticOpts(),
- DiagClient, /*ShouldOwnClient=*/false));
-
- if (outputDir.empty()) {
- origCI.getLangOpts().ObjCAutoRefCount = true;
- return migration.getRemapper().overwriteOriginal(*Diags);
- } else {
- return migration.getRemapper().flushToDisk(outputDir, *Diags);
- }
-}
-
-bool arcmt::applyTransformations(
- CompilerInvocation &origCI, const FrontendInputFile &Input,
- std::shared_ptr<PCHContainerOperations> PCHContainerOps,
- DiagnosticConsumer *DiagClient) {
- return applyTransforms(origCI, Input, PCHContainerOps, DiagClient,
- StringRef(), false, StringRef());
-}
-
-bool arcmt::migrateWithTemporaryFiles(
- CompilerInvocation &origCI, const FrontendInputFile &Input,
- std::shared_ptr<PCHContainerOperations> PCHContainerOps,
- DiagnosticConsumer *DiagClient, StringRef outputDir,
- bool emitPremigrationARCErrors, StringRef plistOut) {
- assert(!outputDir.empty() && "Expected output directory path");
- return applyTransforms(origCI, Input, PCHContainerOps, DiagClient, outputDir,
- emitPremigrationARCErrors, plistOut);
-}
-
-bool arcmt::getFileRemappings(std::vector<std::pair<std::string,std::string> > &
- remap,
- StringRef outputDir,
- DiagnosticConsumer *DiagClient) {
- assert(!outputDir.empty());
-
- IntrusiveRefCntPtr<DiagnosticIDs> DiagID(new DiagnosticIDs());
- IntrusiveRefCntPtr<DiagnosticsEngine> Diags(
- new DiagnosticsEngine(DiagID, new DiagnosticOptions,
- DiagClient, /*ShouldOwnClient=*/false));
-
- FileRemapper remapper;
- bool err = remapper.initFromDisk(outputDir, *Diags,
- /*ignoreIfFilesChanged=*/true);
- if (err)
- return true;
-
- remapper.forEachMapping(
- [&](StringRef From, StringRef To) {
- remap.push_back(std::make_pair(From.str(), To.str()));
- },
- [](StringRef, const llvm::MemoryBufferRef &) {});
-
- return false;
-}
-
-
-//===----------------------------------------------------------------------===//
-// CollectTransformActions.
-//===----------------------------------------------------------------------===//
-
-namespace {
-
-class ARCMTMacroTrackerPPCallbacks : public PPCallbacks {
- std::vector<SourceLocation> &ARCMTMacroLocs;
-
-public:
- ARCMTMacroTrackerPPCallbacks(std::vector<SourceLocation> &ARCMTMacroLocs)
- : ARCMTMacroLocs(ARCMTMacroLocs) { }
-
- void MacroExpands(const Token &MacroNameTok, const MacroDefinition &MD,
- SourceRange Range, const MacroArgs *Args) override {
- if (MacroNameTok.getIdentifierInfo()->getName() == getARCMTMacroName())
- ARCMTMacroLocs.push_back(MacroNameTok.getLocation());
- }
-};
-
-class ARCMTMacroTrackerAction : public ASTFrontendAction {
- std::vector<SourceLocation> &ARCMTMacroLocs;
-
-public:
- ARCMTMacroTrackerAction(std::vector<SourceLocation> &ARCMTMacroLocs)
- : ARCMTMacroLocs(ARCMTMacroLocs) { }
-
- std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI,
- StringRef InFile) override {
- CI.getPreprocessor().addPPCallbacks(
- std::make_unique<ARCMTMacroTrackerPPCallbacks>(ARCMTMacroLocs));
- return std::make_unique<ASTConsumer>();
- }
-};
-
-class RewritesApplicator : public TransformActions::RewriteReceiver {
- Rewriter &rewriter;
- MigrationProcess::RewriteListener *Listener;
-
-public:
- RewritesApplicator(Rewriter &rewriter, ASTContext &ctx,
- MigrationProcess::RewriteListener *listener)
- : rewriter(rewriter), Listener(listener) {
- if (Listener)
- Listener->start(ctx);
- }
- ~RewritesApplicator() override {
- if (Listener)
- Listener->finish();
- }
-
- void insert(SourceLocation loc, StringRef text) override {
- bool err = rewriter.InsertText(loc, text, /*InsertAfter=*/true,
- /*indentNewLines=*/true);
- if (!err && Listener)
- Listener->insert(loc, text);
- }
-
- void remove(CharSourceRange range) override {
- Rewriter::RewriteOptions removeOpts;
- removeOpts.IncludeInsertsAtBeginOfRange = false;
- removeOpts.IncludeInsertsAtEndOfRange = false;
- removeOpts.RemoveLineIfEmpty = true;
-
- bool err = rewriter.RemoveText(range, removeOpts);
- if (!err && Listener)
- Listener->remove(range);
- }
-
- void increaseIndentation(CharSourceRange range,
- SourceLocation parentIndent) override {
- rewriter.IncreaseIndentation(range, parentIndent);
- }
-};
-
-} // end anonymous namespace.
-
-/// Anchor for VTable.
-MigrationProcess::RewriteListener::~RewriteListener() { }
-
-MigrationProcess::MigrationProcess(
- CompilerInvocation &CI,
- std::shared_ptr<PCHContainerOperations> PCHContainerOps,
- DiagnosticConsumer *diagClient, StringRef outputDir)
- : OrigCI(CI), PCHContainerOps(std::move(PCHContainerOps)),
- DiagClient(diagClient), HadARCErrors(false) {
- if (!outputDir.empty()) {
- IntrusiveRefCntPtr<DiagnosticIDs> DiagID(new DiagnosticIDs());
- IntrusiveRefCntPtr<DiagnosticsEngine> Diags(
- new DiagnosticsEngine(DiagID, &CI.getDiagnosticOpts(),
- DiagClient, /*ShouldOwnClient=*/false));
- Remapper.initFromDisk(outputDir, *Diags, /*ignoreIfFilesChanged=*/true);
- }
-}
-
-bool MigrationProcess::applyTransform(TransformFn trans,
- RewriteListener *listener) {
- std::unique_ptr<CompilerInvocation> CInvok;
- CInvok.reset(
- createInvocationForMigration(OrigCI, PCHContainerOps->getRawReader()));
- CInvok->getDiagnosticOpts().IgnoreWarnings = true;
-
- Remapper.applyMappings(CInvok->getPreprocessorOpts());
-
- CapturedDiagList capturedDiags;
- std::vector<SourceLocation> ARCMTMacroLocs;
-
- assert(DiagClient);
- IntrusiveRefCntPtr<DiagnosticIDs> DiagID(new DiagnosticIDs());
- IntrusiveRefCntPtr<DiagnosticsEngine> Diags(
- new DiagnosticsEngine(DiagID, new DiagnosticOptions,
- DiagClient, /*ShouldOwnClient=*/false));
-
- // Filter of all diagnostics.
- CaptureDiagnosticConsumer errRec(*Diags, *DiagClient, capturedDiags);
- Diags->setClient(&errRec, /*ShouldOwnClient=*/false);
-
- std::unique_ptr<ARCMTMacroTrackerAction> ASTAction;
- ASTAction.reset(new ARCMTMacroTrackerAction(ARCMTMacroLocs));
-
- std::unique_ptr<ASTUnit> Unit(ASTUnit::LoadFromCompilerInvocationAction(
- std::move(CInvok), PCHContainerOps, Diags, ASTAction.get()));
- if (!Unit) {
- errRec.FinishCapture();
- return true;
- }
- Unit->setOwnsRemappedFileBuffers(false); // FileRemapper manages that.
-
- HadARCErrors = HadARCErrors || capturedDiags.hasErrors();
-
- // Don't filter diagnostics anymore.
- Diags->setClient(DiagClient, /*ShouldOwnClient=*/false);
-
- ASTContext &Ctx = Unit->getASTContext();
-
- if (Diags->hasFatalErrorOccurred()) {
- Diags->Reset();
- DiagClient->BeginSourceFile(Ctx.getLangOpts(), &Unit->getPreprocessor());
- capturedDiags.reportDiagnostics(*Diags);
- DiagClient->EndSourceFile();
- errRec.FinishCapture();
- return true;
- }
-
- // After parsing of source files ended, we want to reuse the
- // diagnostics objects to emit further diagnostics.
- // We call BeginSourceFile because DiagnosticConsumer requires that
- // diagnostics with source range information are emitted only in between
- // BeginSourceFile() and EndSourceFile().
- DiagClient->BeginSourceFile(Ctx.getLangOpts(), &Unit->getPreprocessor());
-
- Rewriter rewriter(Ctx.getSourceManager(), Ctx.getLangOpts());
- TransformActions TA(*Diags, capturedDiags, Ctx, Unit->getPreprocessor());
- MigrationPass pass(Ctx, OrigCI.getLangOpts().getGC(),
- Unit->getSema(), TA, capturedDiags, ARCMTMacroLocs);
-
- trans(pass);
-
- {
- RewritesApplicator applicator(rewriter, Ctx, listener);
- TA.applyRewrites(applicator);
- }
-
- DiagClient->EndSourceFile();
- errRec.FinishCapture();
-
- if (DiagClient->getNumErrors())
- return true;
-
- for (Rewriter::buffer_iterator
- I = rewriter.buffer_begin(), E = rewriter.buffer_end(); I != E; ++I) {
- FileID FID = I->first;
- llvm::RewriteBuffer &buf = I->second;
- OptionalFileEntryRef file =
- Ctx.getSourceManager().getFileEntryRefForID(FID);
- assert(file);
- std::string newFname = std::string(file->getName());
- newFname += "-trans";
- SmallString<512> newText;
- llvm::raw_svector_ostream vecOS(newText);
- buf.write(vecOS);
- std::unique_ptr<llvm::MemoryBuffer> memBuf(
- llvm::MemoryBuffer::getMemBufferCopy(newText.str(), newFname));
- SmallString<64> filePath(file->getName());
- Unit->getFileManager().FixupRelativePath(filePath);
- Remapper.remap(filePath.str(), std::move(memBuf));
- }
-
- return false;
-}
diff --git a/clang/lib/ARCMigrate/ARCMTActions.cpp b/clang/lib/ARCMigrate/ARCMTActions.cpp
deleted file mode 100644
index 0805d90d25aa62..00000000000000
--- a/clang/lib/ARCMigrate/ARCMTActions.cpp
+++ /dev/null
@@ -1,59 +0,0 @@
-//===--- ARCMTActions.cpp - ARC Migrate Tool Frontend Actions ---*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#include "clang/ARCMigrate/ARCMTActions.h"
-#include "clang/ARCMigrate/ARCMT.h"
-#include "clang/Frontend/CompilerInstance.h"
-
-using namespace clang;
-using namespace arcmt;
-
-bool CheckAction::BeginInvocation(CompilerInstance &CI) {
- if (arcmt::checkForManualIssues(CI.getInvocation(), getCurrentInput(),
- CI.getPCHContainerOperations(),
- CI.getDiagnostics().getClient()))
- return false; // errors, stop the action.
-
- // We only want to see warnings reported from arcmt::checkForManualIssues.
- CI.getDiagnostics().setIgnoreAllWarnings(true);
- return true;
-}
-
-CheckAction::CheckAction(std::unique_ptr<FrontendAction> WrappedAction)
- : WrapperFrontendAction(std::move(WrappedAction)) {}
-
-bool ModifyAction::BeginInvocation(CompilerInstance &CI) {
- return !arcmt::applyTransformations(CI.getInvocation(), getCurrentInput(),
- CI.getPCHContainerOperations(),
- CI.getDiagnostics().getClient());
-}
-
-ModifyAction::ModifyAction(std::unique_ptr<FrontendAction> WrappedAction)
- : WrapperFrontendAction(std::move(WrappedAction)) {}
-
-bool MigrateAction::BeginInvocation(CompilerInstance &CI) {
- if (arcmt::migrateWithTemporaryFiles(
- CI.getInvocation(), getCurrentInput(), CI.getPCHContainerOperations(),
- CI.getDiagnostics().getClient(), MigrateDir, EmitPremigrationARCErrors,
- PlistOut))
- return false; // errors, stop the action.
-
- // We only want to see diagnostics emitted by migrateWithTemporaryFiles.
- CI.getDiagnostics().setIgnoreAllWarnings(true);
- return true;
-}
-
-MigrateAction::MigrateAction(std::unique_ptr<FrontendAction> WrappedAction,
- StringRef migrateDir,
- StringRef plistOut,
- bool emitPremigrationARCErrors)
- : WrapperFrontendAction(std::move(WrappedAction)), MigrateDir(migrateDir),
- PlistOut(plistOut), EmitPremigrationARCErrors(emitPremigrationARCErrors) {
- if (MigrateDir.empty())
- MigrateDir = "."; // user current directory if none is given.
-}
diff --git a/clang/lib/ARCMigrate/CMakeLists.txt b/clang/lib/ARCMigrate/CMakeLists.txt
deleted file mode 100644
index 515d0960920afc..00000000000000
--- a/clang/lib/ARCMigrate/CMakeLists.txt
+++ /dev/null
@@ -1,48 +0,0 @@
-set(LLVM_LINK_COMPONENTS
- Support
- TargetParser
- )
-
-# By default MSVC has a 2^16 limit on the number of sections in an object
-# file, and Transforms.cpp needs more than that.
-if (MSVC)
- set_source_files_properties(Transforms.cpp PROPERTIES COMPILE_FLAGS /bigobj)
-endif()
-
-add_clang_library(clangARCMigrate
- ARCMT.cpp
- ARCMTActions.cpp
- FileRemapper.cpp
- ObjCMT.cpp
- PlistReporter.cpp
- TransAPIUses.cpp
- TransARCAssign.cpp
- TransAutoreleasePool.cpp
- TransBlockObjCVariable.cpp
- TransEmptyStatementsAndDealloc.cpp
- TransGCAttrs.cpp
- TransGCCalls.cpp
- TransProperties.cpp
- TransProtectedScope.cpp
- TransRetainReleaseDealloc.cpp
- TransUnbridgedCasts.cpp
- TransUnusedInitDelegate.cpp
- TransZeroOutPropsInDealloc.cpp
- TransformActions.cpp
- Transforms.cpp
-
- LINK_LIBS
- clangAST
- clangAnalysis
- clangBasic
- clangEdit
- clangFrontend
- clangLex
- clangRewrite
- clangSema
- clangSerialization
-
- DEPENDS
- omp_gen
- ClangDriverOptions
- )
diff --git a/clang/lib/ARCMigrate/FileRemapper.cpp b/clang/lib/ARCMigrate/FileRemapper.cpp
deleted file mode 100644
index 84024c3bafdca0..00000000000000
--- a/clang/lib/ARCMigrate/FileRemapper.cpp
+++ /dev/null
@@ -1,274 +0,0 @@
-//===--- FileRemapper.cpp - File Remapping Helper -------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#include "clang/ARCMigrate/FileRemapper.h"
-#include "clang/Basic/Diagnostic.h"
-#include "clang/Basic/FileManager.h"
-#include "clang/Lex/PreprocessorOptions.h"
-#include "llvm/Support/FileSystem.h"
-#include "llvm/Support/MemoryBuffer.h"
-#include "llvm/Support/Path.h"
-#include "llvm/Support/raw_ostream.h"
-#include <fstream>
-
-using namespace clang;
-using namespace arcmt;
-
-FileRemapper::FileRemapper() {
- FileMgr.reset(new FileManager(FileSystemOptions()));
-}
-
-FileRemapper::~FileRemapper() {
- clear();
-}
-
-void FileRemapper::clear(StringRef outputDir) {
- for (MappingsTy::iterator
- I = FromToMappings.begin(), E = FromToMappings.end(); I != E; ++I)
- resetTarget(I->second);
- FromToMappings.clear();
- assert(ToFromMappings.empty());
- if (!outputDir.empty()) {
- std::string infoFile = getRemapInfoFile(outputDir);
- llvm::sys::fs::remove(infoFile);
- }
-}
-
-std::string FileRemapper::getRemapInfoFile(StringRef outputDir) {
- assert(!outputDir.empty());
- SmallString<128> InfoFile = outputDir;
- llvm::sys::path::append(InfoFile, "remap");
- return std::string(InfoFile);
-}
-
-bool FileRemapper::initFromDisk(StringRef outputDir, DiagnosticsEngine &Diag,
- bool ignoreIfFilesChanged) {
- std::string infoFile = getRemapInfoFile(outputDir);
- return initFromFile(infoFile, Diag, ignoreIfFilesChanged);
-}
-
-bool FileRemapper::initFromFile(StringRef filePath, DiagnosticsEngine &Diag,
- bool ignoreIfFilesChanged) {
- assert(FromToMappings.empty() &&
- "initFromDisk should be called before any remap calls");
- std::string infoFile = std::string(filePath);
- if (!llvm::sys::fs::exists(infoFile))
- return false;
-
- std::vector<std::pair<FileEntryRef, FileEntryRef>> pairs;
-
- llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> fileBuf =
- llvm::MemoryBuffer::getFile(infoFile, /*IsText=*/true);
- if (!fileBuf)
- return report("Error opening file: " + infoFile, Diag);
-
- SmallVector<StringRef, 64> lines;
- fileBuf.get()->getBuffer().split(lines, "\n");
-
- for (unsigned idx = 0; idx+3 <= lines.size(); idx += 3) {
- StringRef fromFilename = lines[idx];
- unsigned long long timeModified;
- if (lines[idx+1].getAsInteger(10, timeModified))
- return report("Invalid file data: '" + lines[idx+1] + "' not a number",
- Diag);
- StringRef toFilename = lines[idx+2];
-
- auto origFE = FileMgr->getOptionalFileRef(fromFilename);
- if (!origFE) {
- if (ignoreIfFilesChanged)
- continue;
- return report("File does not exist: " + fromFilename, Diag);
- }
- auto newFE = FileMgr->getOptionalFileRef(toFilename);
- if (!newFE) {
- if (ignoreIfFilesChanged)
- continue;
- return report("File does not exist: " + toFilename, Diag);
- }
-
- if ((uint64_t)origFE->getModificationTime() != timeModified) {
- if (ignoreIfFilesChanged)
- continue;
- return report("File was modified: " + fromFilename, Diag);
- }
-
- pairs.push_back(std::make_pair(*origFE, *newFE));
- }
-
- for (unsigned i = 0, e = pairs.size(); i != e; ++i)
- remap(pairs[i].first, pairs[i].second);
-
- return false;
-}
-
-bool FileRemapper::flushToDisk(StringRef outputDir, DiagnosticsEngine &Diag) {
- using namespace llvm::sys;
-
- if (fs::create_directory(outputDir))
- return report("Could not create directory: " + outputDir, Diag);
-
- std::string infoFile = getRemapInfoFile(outputDir);
- return flushToFile(infoFile, Diag);
-}
-
-bool FileRemapper::flushToFile(StringRef outputPath, DiagnosticsEngine &Diag) {
- using namespace llvm::sys;
-
- std::error_code EC;
- std::string infoFile = std::string(outputPath);
- llvm::raw_fd_ostream infoOut(infoFile, EC, llvm::sys::fs::OF_Text);
- if (EC)
- return report(EC.message(), Diag);
-
- for (MappingsTy::iterator
- I = FromToMappings.begin(), E = FromToMappings.end(); I != E; ++I) {
-
- FileEntryRef origFE = I->first;
- SmallString<200> origPath = StringRef(origFE.getName());
- fs::make_absolute(origPath);
- infoOut << origPath << '\n';
- infoOut << (uint64_t)origFE.getModificationTime() << '\n';
-
- if (const auto *FE = std::get_if<FileEntryRef>(&I->second)) {
- SmallString<200> newPath = StringRef(FE->getName());
- fs::make_absolute(newPath);
- infoOut << newPath << '\n';
- } else {
-
- SmallString<64> tempPath;
- int fd;
- if (fs::createTemporaryFile(
- path::filename(origFE.getName()),
- path::extension(origFE.getName()).drop_front(), fd, tempPath,
- llvm::sys::fs::OF_Text))
- return report("Could not create file: " + tempPath.str(), Diag);
-
- llvm::raw_fd_ostream newOut(fd, /*shouldClose=*/true);
- llvm::MemoryBuffer *mem = std::get<llvm::MemoryBuffer *>(I->second);
- newOut.write(mem->getBufferStart(), mem->getBufferSize());
- newOut.close();
-
- auto newE = FileMgr->getOptionalFileRef(tempPath);
- if (newE) {
- remap(origFE, *newE);
- infoOut << newE->getName() << '\n';
- }
- }
- }
-
- infoOut.close();
- return false;
-}
-
-bool FileRemapper::overwriteOriginal(DiagnosticsEngine &Diag,
- StringRef outputDir) {
- using namespace llvm::sys;
-
- for (MappingsTy::iterator
- I = FromToMappings.begin(), E = FromToMappings.end(); I != E; ++I) {
- FileEntryRef origFE = I->first;
- assert(std::holds_alternative<llvm::MemoryBuffer *>(I->second));
- if (!fs::exists(origFE.getName()))
- return report(StringRef("File does not exist: ") + origFE.getName(),
- Diag);
-
- std::error_code EC;
- llvm::raw_fd_ostream Out(origFE.getName(), EC, llvm::sys::fs::OF_None);
- if (EC)
- return report(EC.message(), Diag);
-
- llvm::MemoryBuffer *mem = std::get<llvm::MemoryBuffer *>(I->second);
- Out.write(mem->getBufferStart(), mem->getBufferSize());
- Out.close();
- }
-
- clear(outputDir);
- return false;
-}
-
-void FileRemapper::forEachMapping(
- llvm::function_ref<void(StringRef, StringRef)> CaptureFile,
- llvm::function_ref<void(StringRef, const llvm::MemoryBufferRef &)>
- CaptureBuffer) const {
- for (auto &Mapping : FromToMappings) {
- if (const auto *FE = std::get_if<FileEntryRef>(&Mapping.second)) {
- CaptureFile(Mapping.first.getName(), FE->getName());
- continue;
- }
- CaptureBuffer(
- Mapping.first.getName(),
- std::get<llvm::MemoryBuffer *>(Mapping.second)->getMemBufferRef());
- }
-}
-
-void FileRemapper::applyMappings(PreprocessorOptions &PPOpts) const {
- for (MappingsTy::const_iterator
- I = FromToMappings.begin(), E = FromToMappings.end(); I != E; ++I) {
- if (const auto *FE = std::get_if<FileEntryRef>(&I->second)) {
- PPOpts.addRemappedFile(I->first.getName(), FE->getName());
- } else {
- llvm::MemoryBuffer *mem = std::get<llvm::MemoryBuffer *>(I->second);
- PPOpts.addRemappedFile(I->first.getName(), mem);
- }
- }
-
- PPOpts.RetainRemappedFileBuffers = true;
-}
-
-void FileRemapper::remap(StringRef filePath,
- std::unique_ptr<llvm::MemoryBuffer> memBuf) {
- OptionalFileEntryRef File = getOriginalFile(filePath);
- assert(File);
- remap(*File, std::move(memBuf));
-}
-
-void FileRemapper::remap(FileEntryRef File,
- std::unique_ptr<llvm::MemoryBuffer> MemBuf) {
- auto [It, New] = FromToMappings.insert({File, nullptr});
- if (!New)
- resetTarget(It->second);
- It->second = MemBuf.release();
-}
-
-void FileRemapper::remap(FileEntryRef File, FileEntryRef NewFile) {
- auto [It, New] = FromToMappings.insert({File, nullptr});
- if (!New)
- resetTarget(It->second);
- It->second = NewFile;
- ToFromMappings.insert({NewFile, File});
-}
-
-OptionalFileEntryRef FileRemapper::getOriginalFile(StringRef filePath) {
- OptionalFileEntryRef File = FileMgr->getOptionalFileRef(filePath);
- if (!File)
- return std::nullopt;
- // If we are updating a file that overridden an original file,
- // actually update the original file.
- auto I = ToFromMappings.find(*File);
- if (I != ToFromMappings.end()) {
- *File = I->second;
- assert(FromToMappings.contains(*File) && "Original file not in mappings!");
- }
- return File;
-}
-
-void FileRemapper::resetTarget(Target &targ) {
- if (std::holds_alternative<llvm::MemoryBuffer *>(targ)) {
- llvm::MemoryBuffer *oldmem = std::get<llvm::MemoryBuffer *>(targ);
- delete oldmem;
- } else {
- FileEntryRef toFE = std::get<FileEntryRef>(targ);
- ToFromMappings.erase(toFE);
- }
-}
-
-bool FileRemapper::report(const Twine &err, DiagnosticsEngine &Diag) {
- Diag.Report(Diag.getCustomDiagID(DiagnosticsEngine::Error, "%0"))
- << err.str();
- return true;
-}
diff --git a/clang/lib/ARCMigrate/Internals.h b/clang/lib/ARCMigrate/Internals.h
deleted file mode 100644
index de6ebdce1bea16..00000000000000
--- a/clang/lib/ARCMigrate/Internals.h
+++ /dev/null
@@ -1,180 +0,0 @@
-//===-- Internals.h - Implementation Details---------------------*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_CLANG_LIB_ARCMIGRATE_INTERNALS_H
-#define LLVM_CLANG_LIB_ARCMIGRATE_INTERNALS_H
-
-#include "clang/Basic/LangOptions.h"
-#include "clang/Basic/Diagnostic.h"
-#include "clang/Frontend/MigratorOptions.h"
-#include "llvm/ADT/ArrayRef.h"
-#include <list>
-#include <optional>
-
-namespace clang {
- class ASTContext;
- class Sema;
- class Stmt;
-
-namespace arcmt {
-
-class CapturedDiagList {
- typedef std::list<StoredDiagnostic> ListTy;
- ListTy List;
-
-public:
- void push_back(const StoredDiagnostic &diag) { List.push_back(diag); }
-
- bool clearDiagnostic(ArrayRef<unsigned> IDs, SourceRange range);
- bool hasDiagnostic(ArrayRef<unsigned> IDs, SourceRange range) const;
-
- void reportDiagnostics(DiagnosticsEngine &diags) const;
-
- bool hasErrors() const;
-
- typedef ListTy::const_iterator iterator;
- iterator begin() const { return List.begin(); }
- iterator end() const { return List.end(); }
-};
-
-void writeARCDiagsToPlist(const std::string &outPath,
- ArrayRef<StoredDiagnostic> diags,
- SourceManager &SM, const LangOptions &LangOpts);
-
-class TransformActions {
- DiagnosticsEngine &Diags;
- CapturedDiagList &CapturedDiags;
- void *Impl; // TransformActionsImpl.
-
-public:
- TransformActions(DiagnosticsEngine &diag, CapturedDiagList &capturedDiags,
- ASTContext &ctx, Preprocessor &PP);
- ~TransformActions();
-
- void startTransaction();
- bool commitTransaction();
- void abortTransaction();
-
- void insert(SourceLocation loc, StringRef text);
- void insertAfterToken(SourceLocation loc, StringRef text);
- void remove(SourceRange range);
- void removeStmt(Stmt *S);
- void replace(SourceRange range, StringRef text);
- void replace(SourceRange range, SourceRange replacementRange);
- void replaceStmt(Stmt *S, StringRef text);
- void replaceText(SourceLocation loc, StringRef text,
- StringRef replacementText);
- void increaseIndentation(SourceRange range,
- SourceLocation parentIndent);
-
- bool clearDiagnostic(ArrayRef<unsigned> IDs, SourceRange range);
- bool clearAllDiagnostics(SourceRange range) {
- return clearDiagnostic({}, range);
- }
- bool clearDiagnostic(unsigned ID1, unsigned ID2, SourceRange range) {
- unsigned IDs[] = { ID1, ID2 };
- return clearDiagnostic(IDs, range);
- }
- bool clearDiagnostic(unsigned ID1, unsigned ID2, unsigned ID3,
- SourceRange range) {
- unsigned IDs[] = { ID1, ID2, ID3 };
- return clearDiagnostic(IDs, range);
- }
-
- bool hasDiagnostic(unsigned ID, SourceRange range) {
- return CapturedDiags.hasDiagnostic(ID, range);
- }
-
- bool hasDiagnostic(unsigned ID1, unsigned ID2, SourceRange range) {
- unsigned IDs[] = { ID1, ID2 };
- return CapturedDiags.hasDiagnostic(IDs, range);
- }
-
- DiagnosticBuilder report(SourceLocation loc, unsigned diagId,
- SourceRange range = SourceRange());
- void reportError(StringRef error, SourceLocation loc,
- SourceRange range = SourceRange());
- void reportWarning(StringRef warning, SourceLocation loc,
- SourceRange range = SourceRange());
- void reportNote(StringRef note, SourceLocation loc,
- SourceRange range = SourceRange());
-
- bool hasReportedErrors() const {
- return Diags.hasUnrecoverableErrorOccurred();
- }
-
- class RewriteReceiver {
- public:
- virtual ~RewriteReceiver();
-
- virtual void insert(SourceLocation loc, StringRef text) = 0;
- virtual void remove(CharSourceRange range) = 0;
- virtual void increaseIndentation(CharSourceRange range,
- SourceLocation parentIndent) = 0;
- };
-
- void applyRewrites(RewriteReceiver &receiver);
-};
-
-class Transaction {
- TransformActions &TA;
- bool Aborted;
-
-public:
- Transaction(TransformActions &TA) : TA(TA), Aborted(false) {
- TA.startTransaction();
- }
-
- ~Transaction() {
- if (!isAborted())
- TA.commitTransaction();
- }
-
- void abort() {
- TA.abortTransaction();
- Aborted = true;
- }
-
- bool isAborted() const { return Aborted; }
-};
-
-class MigrationPass {
-public:
- ASTContext &Ctx;
- LangOptions::GCMode OrigGCMode;
- MigratorOptions MigOptions;
- Sema &SemaRef;
- TransformActions &TA;
- const CapturedDiagList &CapturedDiags;
- std::vector<SourceLocation> &ARCMTMacroLocs;
- std::optional<bool> EnableCFBridgeFns;
-
- MigrationPass(ASTContext &Ctx, LangOptions::GCMode OrigGCMode, Sema &sema,
- TransformActions &TA, const CapturedDiagList &capturedDiags,
- std::vector<SourceLocation> &ARCMTMacroLocs)
- : Ctx(Ctx), OrigGCMode(OrigGCMode), SemaRef(sema), TA(TA),
- CapturedDiags(capturedDiags), ARCMTMacroLocs(ARCMTMacroLocs) {}
-
- const CapturedDiagList &getDiags() const { return CapturedDiags; }
-
- bool isGCMigration() const { return OrigGCMode != LangOptions::NonGC; }
- bool noFinalizeRemoval() const { return MigOptions.NoFinalizeRemoval; }
- void setNoFinalizeRemoval(bool val) {MigOptions.NoFinalizeRemoval = val; }
-
- bool CFBridgingFunctionsDefined();
-};
-
-static inline StringRef getARCMTMacroName() {
- return "__IMPL_ARCMT_REMOVED_EXPR__";
-}
-
-} // end namespace arcmt
-
-} // end namespace clang
-
-#endif
diff --git a/clang/lib/ARCMigrate/ObjCMT.cpp b/clang/lib/ARCMigrate/ObjCMT.cpp
deleted file mode 100644
index c1bc7c762088f2..00000000000000
--- a/clang/lib/ARCMigrate/ObjCMT.cpp
+++ /dev/null
@@ -1,2262 +0,0 @@
-//===--- ObjCMT.cpp - ObjC Migrate Tool -----------------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#include "Transforms.h"
-#include "clang/Analysis/RetainSummaryManager.h"
-#include "clang/ARCMigrate/ARCMT.h"
-#include "clang/ARCMigrate/ARCMTActions.h"
-#include "clang/AST/ASTConsumer.h"
-#include "clang/AST/ASTContext.h"
-#include "clang/AST/Attr.h"
-#include "clang/AST/NSAPI.h"
-#include "clang/AST/ParentMap.h"
-#include "clang/AST/RecursiveASTVisitor.h"
-#include "clang/Analysis/DomainSpecific/CocoaConventions.h"
-#include "clang/Basic/FileManager.h"
-#include "clang/Edit/Commit.h"
-#include "clang/Edit/EditedSource.h"
-#include "clang/Edit/EditsReceiver.h"
-#include "clang/Edit/Rewriters.h"
-#include "clang/Frontend/CompilerInstance.h"
-#include "clang/Frontend/MultiplexConsumer.h"
-#include "clang/Lex/PPConditionalDirectiveRecord.h"
-#include "clang/Lex/Preprocessor.h"
-#include "clang/Rewrite/Core/Rewriter.h"
-#include "llvm/ADT/SmallString.h"
-#include "llvm/ADT/StringSet.h"
-#include "llvm/Support/Path.h"
-#include "llvm/Support/SourceMgr.h"
-#include "llvm/Support/YAMLParser.h"
-
-using namespace clang;
-using namespace arcmt;
-using namespace ento;
-using llvm::RewriteBuffer;
-
-namespace {
-
-class ObjCMigrateASTConsumer : public ASTConsumer {
- enum CF_BRIDGING_KIND {
- CF_BRIDGING_NONE,
- CF_BRIDGING_ENABLE,
- CF_BRIDGING_MAY_INCLUDE
- };
-
- void migrateDecl(Decl *D);
- void migrateObjCContainerDecl(ASTContext &Ctx, ObjCContainerDecl *D);
- void migrateProtocolConformance(ASTContext &Ctx,
- const ObjCImplementationDecl *ImpDecl);
- void CacheObjCNSIntegerTypedefed(const TypedefDecl *TypedefDcl);
- bool migrateNSEnumDecl(ASTContext &Ctx, const EnumDecl *EnumDcl,
- const TypedefDecl *TypedefDcl);
- void migrateAllMethodInstaceType(ASTContext &Ctx, ObjCContainerDecl *CDecl);
- void migrateMethodInstanceType(ASTContext &Ctx, ObjCContainerDecl *CDecl,
- ObjCMethodDecl *OM);
- bool migrateProperty(ASTContext &Ctx, ObjCContainerDecl *D, ObjCMethodDecl *OM);
- void migrateNsReturnsInnerPointer(ASTContext &Ctx, ObjCMethodDecl *OM);
- void migratePropertyNsReturnsInnerPointer(ASTContext &Ctx, ObjCPropertyDecl *P);
- void migrateFactoryMethod(ASTContext &Ctx, ObjCContainerDecl *CDecl,
- ObjCMethodDecl *OM,
- ObjCInstanceTypeFamily OIT_Family = OIT_None);
-
- void migrateCFAnnotation(ASTContext &Ctx, const Decl *Decl);
- void AddCFAnnotations(ASTContext &Ctx,
- const RetainSummary *RS,
- const FunctionDecl *FuncDecl, bool ResultAnnotated);
- void AddCFAnnotations(ASTContext &Ctx,
- const RetainSummary *RS,
- const ObjCMethodDecl *MethodDecl, bool ResultAnnotated);
-
- void AnnotateImplicitBridging(ASTContext &Ctx);
-
- CF_BRIDGING_KIND migrateAddFunctionAnnotation(ASTContext &Ctx,
- const FunctionDecl *FuncDecl);
-
- void migrateARCSafeAnnotation(ASTContext &Ctx, ObjCContainerDecl *CDecl);
-
- void migrateAddMethodAnnotation(ASTContext &Ctx,
- const ObjCMethodDecl *MethodDecl);
-
- void inferDesignatedInitializers(ASTContext &Ctx,
- const ObjCImplementationDecl *ImplD);
-
- bool InsertFoundation(ASTContext &Ctx, SourceLocation Loc);
-
- std::unique_ptr<RetainSummaryManager> Summaries;
-
-public:
- std::string MigrateDir;
- unsigned ASTMigrateActions;
- FileID FileId;
- const TypedefDecl *NSIntegerTypedefed;
- const TypedefDecl *NSUIntegerTypedefed;
- std::unique_ptr<NSAPI> NSAPIObj;
- std::unique_ptr<edit::EditedSource> Editor;
- FileRemapper &Remapper;
- FileManager &FileMgr;
- const PPConditionalDirectiveRecord *PPRec;
- Preprocessor &PP;
- bool IsOutputFile;
- bool FoundationIncluded;
- llvm::SmallPtrSet<ObjCProtocolDecl *, 32> ObjCProtocolDecls;
- llvm::SmallVector<const Decl *, 8> CFFunctionIBCandidates;
- llvm::StringSet<> AllowListFilenames;
-
- RetainSummaryManager &getSummaryManager(ASTContext &Ctx) {
- if (!Summaries)
- Summaries.reset(new RetainSummaryManager(Ctx,
- /*TrackNSCFObjects=*/true,
- /*trackOSObjects=*/false));
- return *Summaries;
- }
-
- ObjCMigrateASTConsumer(StringRef migrateDir, unsigned astMigrateActions,
- FileRemapper &remapper, FileManager &fileMgr,
- const PPConditionalDirectiveRecord *PPRec,
- Preprocessor &PP, bool isOutputFile,
- ArrayRef<std::string> AllowList)
- : MigrateDir(migrateDir), ASTMigrateActions(astMigrateActions),
- NSIntegerTypedefed(nullptr), NSUIntegerTypedefed(nullptr),
- Remapper(remapper), FileMgr(fileMgr), PPRec(PPRec), PP(PP),
- IsOutputFile(isOutputFile), FoundationIncluded(false) {
- AllowListFilenames.insert(AllowList.begin(), AllowList.end());
- }
-
-protected:
- void Initialize(ASTContext &Context) override {
- NSAPIObj.reset(new NSAPI(Context));
- Editor.reset(new edit::EditedSource(Context.getSourceManager(),
- Context.getLangOpts(),
- PPRec));
- }
-
- bool HandleTopLevelDecl(DeclGroupRef DG) override {
- for (DeclGroupRef::iterator I = DG.begin(), E = DG.end(); I != E; ++I)
- migrateDecl(*I);
- return true;
- }
- void HandleInterestingDecl(DeclGroupRef DG) override {
- // Ignore decls from the PCH.
- }
- void HandleTopLevelDeclInObjCContainer(DeclGroupRef DG) override {
- ObjCMigrateASTConsumer::HandleTopLevelDecl(DG);
- }
-
- void HandleTranslationUnit(ASTContext &Ctx) override;
-
- bool canModifyFile(StringRef Path) {
- if (AllowListFilenames.empty())
- return true;
- return AllowListFilenames.contains(llvm::sys::path::filename(Path));
- }
- bool canModifyFile(OptionalFileEntryRef FE) {
- if (!FE)
- return false;
- return canModifyFile(FE->getName());
- }
- bool canModifyFile(FileID FID) {
- if (FID.isInvalid())
- return false;
- return canModifyFile(PP.getSourceManager().getFileEntryRefForID(FID));
- }
-
- bool canModify(const Decl *D) {
- if (!D)
- return false;
- if (const ObjCCategoryImplDecl *CatImpl = dyn_cast<ObjCCategoryImplDecl>(D))
- return canModify(CatImpl->getCategoryDecl());
- if (const ObjCImplementationDecl *Impl = dyn_cast<ObjCImplementationDecl>(D))
- return canModify(Impl->getClassInterface());
- if (const ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(D))
- return canModify(cast<Decl>(MD->getDeclContext()));
-
- FileID FID = PP.getSourceManager().getFileID(D->getLocation());
- return canModifyFile(FID);
- }
-};
-
-} // end anonymous namespace
-
-ObjCMigrateAction::ObjCMigrateAction(
- std::unique_ptr<FrontendAction> WrappedAction, StringRef migrateDir,
- unsigned migrateAction)
- : WrapperFrontendAction(std::move(WrappedAction)), MigrateDir(migrateDir),
- ObjCMigAction(migrateAction), CompInst(nullptr) {
- if (MigrateDir.empty())
- MigrateDir = "."; // user current directory if none is given.
-}
-
-std::unique_ptr<ASTConsumer>
-ObjCMigrateAction::CreateASTConsumer(CompilerInstance &CI, StringRef InFile) {
- PPConditionalDirectiveRecord *
- PPRec = new PPConditionalDirectiveRecord(CompInst->getSourceManager());
- CI.getPreprocessor().addPPCallbacks(std::unique_ptr<PPCallbacks>(PPRec));
- std::vector<std::unique_ptr<ASTConsumer>> Consumers;
- Consumers.push_back(WrapperFrontendAction::CreateASTConsumer(CI, InFile));
- Consumers.push_back(std::make_unique<ObjCMigrateASTConsumer>(
- MigrateDir, ObjCMigAction, Remapper, CompInst->getFileManager(), PPRec,
- CompInst->getPreprocessor(), false, std::nullopt));
- return std::make_unique<MultiplexConsumer>(std::move(Consumers));
-}
-
-bool ObjCMigrateAction::BeginInvocation(CompilerInstance &CI) {
- Remapper.initFromDisk(MigrateDir, CI.getDiagnostics(),
- /*ignoreIfFilesChanged=*/true);
- CompInst = &CI;
- CI.getDiagnostics().setIgnoreAllWarnings(true);
- return true;
-}
-
-namespace {
- // FIXME. This duplicates one in RewriteObjCFoundationAPI.cpp
- bool subscriptOperatorNeedsParens(const Expr *FullExpr) {
- const Expr* Expr = FullExpr->IgnoreImpCasts();
- return !(isa<ArraySubscriptExpr>(Expr) || isa<CallExpr>(Expr) ||
- isa<DeclRefExpr>(Expr) || isa<CXXNamedCastExpr>(Expr) ||
- isa<CXXConstructExpr>(Expr) || isa<CXXThisExpr>(Expr) ||
- isa<CXXTypeidExpr>(Expr) ||
- isa<CXXUnresolvedConstructExpr>(Expr) ||
- isa<ObjCMessageExpr>(Expr) || isa<ObjCPropertyRefExpr>(Expr) ||
- isa<ObjCProtocolExpr>(Expr) || isa<MemberExpr>(Expr) ||
- isa<ObjCIvarRefExpr>(Expr) || isa<ParenExpr>(FullExpr) ||
- isa<ParenListExpr>(Expr) || isa<SizeOfPackExpr>(Expr));
- }
-
- /// - Rewrite message expression for Objective-C setter and getters into
- /// property-dot syntax.
- bool rewriteToPropertyDotSyntax(const ObjCMessageExpr *Msg,
- Preprocessor &PP,
- const NSAPI &NS, edit::Commit &commit,
- const ParentMap *PMap) {
- if (!Msg || Msg->isImplicit() ||
- (Msg->getReceiverKind() != ObjCMessageExpr::Instance &&
- Msg->getReceiverKind() != ObjCMessageExpr::SuperInstance))
- return false;
- if (const Expr *Receiver = Msg->getInstanceReceiver())
- if (Receiver->getType()->isObjCBuiltinType())
- return false;
-
- const ObjCMethodDecl *Method = Msg->getMethodDecl();
- if (!Method)
- return false;
- if (!Method->isPropertyAccessor())
- return false;
-
- const ObjCPropertyDecl *Prop = Method->findPropertyDecl();
- if (!Prop)
- return false;
-
- SourceRange MsgRange = Msg->getSourceRange();
- bool ReceiverIsSuper =
- (Msg->getReceiverKind() == ObjCMessageExpr::SuperInstance);
- // for 'super' receiver is nullptr.
- const Expr *receiver = Msg->getInstanceReceiver();
- bool NeedsParen =
- ReceiverIsSuper ? false : subscriptOperatorNeedsParens(receiver);
- bool IsGetter = (Msg->getNumArgs() == 0);
- if (IsGetter) {
- // Find space location range between receiver expression and getter method.
- SourceLocation BegLoc =
- ReceiverIsSuper ? Msg->getSuperLoc() : receiver->getEndLoc();
- BegLoc = PP.getLocForEndOfToken(BegLoc);
- SourceLocation EndLoc = Msg->getSelectorLoc(0);
- SourceRange SpaceRange(BegLoc, EndLoc);
- std::string PropertyDotString;
- // rewrite getter method expression into: receiver.property or
- // (receiver).property
- if (NeedsParen) {
- commit.insertBefore(receiver->getBeginLoc(), "(");
- PropertyDotString = ").";
- }
- else
- PropertyDotString = ".";
- PropertyDotString += Prop->getName();
- commit.replace(SpaceRange, PropertyDotString);
-
- // remove '[' ']'
- commit.replace(SourceRange(MsgRange.getBegin(), MsgRange.getBegin()), "");
- commit.replace(SourceRange(MsgRange.getEnd(), MsgRange.getEnd()), "");
- } else {
- if (NeedsParen)
- commit.insertWrap("(", receiver->getSourceRange(), ")");
- std::string PropertyDotString = ".";
- PropertyDotString += Prop->getName();
- PropertyDotString += " =";
- const Expr*const* Args = Msg->getArgs();
- const Expr *RHS = Args[0];
- if (!RHS)
- return false;
- SourceLocation BegLoc =
- ReceiverIsSuper ? Msg->getSuperLoc() : receiver->getEndLoc();
- BegLoc = PP.getLocForEndOfToken(BegLoc);
- SourceLocation EndLoc = RHS->getBeginLoc();
- EndLoc = EndLoc.getLocWithOffset(-1);
- const char *colon = PP.getSourceManager().getCharacterData(EndLoc);
- // Add a space after '=' if there is no space between RHS and '='
- if (colon && colon[0] == ':')
- PropertyDotString += " ";
- SourceRange Range(BegLoc, EndLoc);
- commit.replace(Range, PropertyDotString);
- // remove '[' ']'
- commit.replace(SourceRange(MsgRange.getBegin(), MsgRange.getBegin()), "");
- commit.replace(SourceRange(MsgRange.getEnd(), MsgRange.getEnd()), "");
- }
- return true;
- }
-
-class ObjCMigrator : public RecursiveASTVisitor<ObjCMigrator> {
- ObjCMigrateASTConsumer &Consumer;
- ParentMap &PMap;
-
-public:
- ObjCMigrator(ObjCMigrateASTConsumer &consumer, ParentMap &PMap)
- : Consumer(consumer), PMap(PMap) { }
-
- bool shouldVisitTemplateInstantiations() const { return false; }
- bool shouldWalkTypesOfTypeLocs() const { return false; }
-
- bool VisitObjCMessageExpr(ObjCMessageExpr *E) {
- if (Consumer.ASTMigrateActions & FrontendOptions::ObjCMT_Literals) {
- edit::Commit commit(*Consumer.Editor);
- edit::rewriteToObjCLiteralSyntax(E, *Consumer.NSAPIObj, commit, &PMap);
- Consumer.Editor->commit(commit);
- }
-
- if (Consumer.ASTMigrateActions & FrontendOptions::ObjCMT_Subscripting) {
- edit::Commit commit(*Consumer.Editor);
- edit::rewriteToObjCSubscriptSyntax(E, *Consumer.NSAPIObj, commit);
- Consumer.Editor->commit(commit);
- }
-
- if (Consumer.ASTMigrateActions & FrontendOptions::ObjCMT_PropertyDotSyntax) {
- edit::Commit commit(*Consumer.Editor);
- rewriteToPropertyDotSyntax(E, Consumer.PP, *Consumer.NSAPIObj,
- commit, &PMap);
- Consumer.Editor->commit(commit);
- }
-
- return true;
- }
-
- bool TraverseObjCMessageExpr(ObjCMessageExpr *E) {
- // Do depth first; we want to rewrite the subexpressions first so that if
- // we have to move expressions we will move them already rewritten.
- for (Stmt *SubStmt : E->children())
- if (!TraverseStmt(SubStmt))
- return false;
-
- return WalkUpFromObjCMessageExpr(E);
- }
-};
-
-class BodyMigrator : public RecursiveASTVisitor<BodyMigrator> {
- ObjCMigrateASTConsumer &Consumer;
- std::unique_ptr<ParentMap> PMap;
-
-public:
- BodyMigrator(ObjCMigrateASTConsumer &consumer) : Consumer(consumer) { }
-
- bool shouldVisitTemplateInstantiations() const { return false; }
- bool shouldWalkTypesOfTypeLocs() const { return false; }
-
- bool TraverseStmt(Stmt *S) {
- PMap.reset(new ParentMap(S));
- ObjCMigrator(Consumer, *PMap).TraverseStmt(S);
- return true;
- }
-};
-} // end anonymous namespace
-
-void ObjCMigrateASTConsumer::migrateDecl(Decl *D) {
- if (!D)
- return;
- if (isa<ObjCMethodDecl>(D))
- return; // Wait for the ObjC container declaration.
-
- BodyMigrator(*this).TraverseDecl(D);
-}
-
-static void append_attr(std::string &PropertyString, const char *attr,
- bool &LParenAdded) {
- if (!LParenAdded) {
- PropertyString += "(";
- LParenAdded = true;
- }
- else
- PropertyString += ", ";
- PropertyString += attr;
-}
-
-static
-void MigrateBlockOrFunctionPointerTypeVariable(std::string & PropertyString,
- const std::string& TypeString,
- const char *name) {
- const char *argPtr = TypeString.c_str();
- int paren = 0;
- while (*argPtr) {
- switch (*argPtr) {
- case '(':
- PropertyString += *argPtr;
- paren++;
- break;
- case ')':
- PropertyString += *argPtr;
- paren--;
- break;
- case '^':
- case '*':
- PropertyString += (*argPtr);
- if (paren == 1) {
- PropertyString += name;
- name = "";
- }
- break;
- default:
- PropertyString += *argPtr;
- break;
- }
- argPtr++;
- }
-}
-
-static const char *PropertyMemoryAttribute(ASTContext &Context, QualType ArgType) {
- Qualifiers::ObjCLifetime propertyLifetime = ArgType.getObjCLifetime();
- bool RetainableObject = ArgType->isObjCRetainableType();
- if (RetainableObject &&
- (propertyLifetime == Qualifiers::OCL_Strong
- || propertyLifetime == Qualifiers::OCL_None)) {
- if (const ObjCObjectPointerType *ObjPtrTy =
- ArgType->getAs<ObjCObjectPointerType>()) {
- ObjCInterfaceDecl *IDecl = ObjPtrTy->getObjectType()->getInterface();
- if (IDecl &&
- IDecl->lookupNestedProtocol(&Context.Idents.get("NSCopying")))
- return "copy";
- else
- return "strong";
- }
- else if (ArgType->isBlockPointerType())
- return "copy";
- } else if (propertyLifetime == Qualifiers::OCL_Weak)
- // TODO. More precise determination of 'weak' attribute requires
- // looking into setter's implementation for backing weak ivar.
- return "weak";
- else if (RetainableObject)
- return ArgType->isBlockPointerType() ? "copy" : "strong";
- return nullptr;
-}
-
-static void rewriteToObjCProperty(const ObjCMethodDecl *Getter,
- const ObjCMethodDecl *Setter,
- const NSAPI &NS, edit::Commit &commit,
- unsigned LengthOfPrefix,
- bool Atomic, bool UseNsIosOnlyMacro,
- bool AvailabilityArgsMatch) {
- ASTContext &Context = NS.getASTContext();
- bool LParenAdded = false;
- std::string PropertyString = "@property ";
- if (UseNsIosOnlyMacro && NS.isMacroDefined("NS_NONATOMIC_IOSONLY")) {
- PropertyString += "(NS_NONATOMIC_IOSONLY";
- LParenAdded = true;
- } else if (!Atomic) {
- PropertyString += "(nonatomic";
- LParenAdded = true;
- }
-
- std::string PropertyNameString = Getter->getNameAsString();
- StringRef PropertyName(PropertyNameString);
- if (LengthOfPrefix > 0) {
- if (!LParenAdded) {
- PropertyString += "(getter=";
- LParenAdded = true;
- }
- else
- PropertyString += ", getter=";
- PropertyString += PropertyNameString;
- }
- // Property with no setter may be suggested as a 'readonly' property.
- if (!Setter)
- append_attr(PropertyString, "readonly", LParenAdded);
-
-
- // Short circuit 'delegate' properties that contain the name "delegate" or
- // "dataSource", or have exact name "target" to have 'assign' attribute.
- if (PropertyName == "target" || PropertyName.contains("delegate") ||
- PropertyName.contains("dataSource")) {
- QualType QT = Getter->getReturnType();
- if (!QT->isRealType())
- append_attr(PropertyString, "assign", LParenAdded);
- } else if (!Setter) {
- QualType ResType = Context.getCanonicalType(Getter->getReturnType());
- if (const char *MemoryManagementAttr = PropertyMemoryAttribute(Context, ResType))
- append_attr(PropertyString, MemoryManagementAttr, LParenAdded);
- } else {
- const ParmVarDecl *argDecl = *Setter->param_begin();
- QualType ArgType = Context.getCanonicalType(argDecl->getType());
- if (const char *MemoryManagementAttr = PropertyMemoryAttribute(Context, ArgType))
- append_attr(PropertyString, MemoryManagementAttr, LParenAdded);
- }
- if (LParenAdded)
- PropertyString += ')';
- QualType RT = Getter->getReturnType();
- if (!RT->getAs<TypedefType>()) {
- // strip off any ARC lifetime qualifier.
- QualType CanResultTy = Context.getCanonicalType(RT);
- if (CanResultTy.getQualifiers().hasObjCLifetime()) {
- Qualifiers Qs = CanResultTy.getQualifiers();
- Qs.removeObjCLifetime();
- RT = Context.getQualifiedType(CanResultTy.getUnqualifiedType(), Qs);
- }
- }
- PropertyString += " ";
- PrintingPolicy SubPolicy(Context.getPrintingPolicy());
- SubPolicy.SuppressStrongLifetime = true;
- SubPolicy.SuppressLifetimeQualifiers = true;
- std::string TypeString = RT.getAsString(SubPolicy);
- if (LengthOfPrefix > 0) {
- // property name must strip off "is" and lower case the first character
- // after that; e.g. isContinuous will become continuous.
- StringRef PropertyNameStringRef(PropertyNameString);
- PropertyNameStringRef = PropertyNameStringRef.drop_front(LengthOfPrefix);
- PropertyNameString = std::string(PropertyNameStringRef);
- bool NoLowering = (isUppercase(PropertyNameString[0]) &&
- PropertyNameString.size() > 1 &&
- isUppercase(PropertyNameString[1]));
- if (!NoLowering)
- PropertyNameString[0] = toLowercase(PropertyNameString[0]);
- }
- if (RT->isBlockPointerType() || RT->isFunctionPointerType())
- MigrateBlockOrFunctionPointerTypeVariable(PropertyString,
- TypeString,
- PropertyNameString.c_str());
- else {
- char LastChar = TypeString[TypeString.size()-1];
- PropertyString += TypeString;
- if (LastChar != '*')
- PropertyString += ' ';
- PropertyString += PropertyNameString;
- }
- SourceLocation StartGetterSelectorLoc = Getter->getSelectorStartLoc();
- Selector GetterSelector = Getter->getSelector();
-
- SourceLocation EndGetterSelectorLoc =
- StartGetterSelectorLoc.getLocWithOffset(GetterSelector.getNameForSlot(0).size());
- commit.replace(CharSourceRange::getCharRange(Getter->getBeginLoc(),
- EndGetterSelectorLoc),
- PropertyString);
- if (Setter && AvailabilityArgsMatch) {
- SourceLocation EndLoc = Setter->getDeclaratorEndLoc();
- // Get location past ';'
- EndLoc = EndLoc.getLocWithOffset(1);
- SourceLocation BeginOfSetterDclLoc = Setter->getBeginLoc();
- // FIXME. This assumes that setter decl; is immediately preceded by eoln.
- // It is trying to remove the setter method decl. line entirely.
- BeginOfSetterDclLoc = BeginOfSetterDclLoc.getLocWithOffset(-1);
- commit.remove(SourceRange(BeginOfSetterDclLoc, EndLoc));
- }
-}
-
-static bool IsCategoryNameWithDeprecatedSuffix(ObjCContainerDecl *D) {
- if (ObjCCategoryDecl *CatDecl = dyn_cast<ObjCCategoryDecl>(D)) {
- StringRef Name = CatDecl->getName();
- return Name.ends_with("Deprecated");
- }
- return false;
-}
-
-void ObjCMigrateASTConsumer::migrateObjCContainerDecl(ASTContext &Ctx,
- ObjCContainerDecl *D) {
- if (D->isDeprecated() || IsCategoryNameWithDeprecatedSuffix(D))
- return;
-
- for (auto *Method : D->methods()) {
- if (Method->isDeprecated())
- continue;
- bool PropertyInferred = migrateProperty(Ctx, D, Method);
- // If a property is inferred, do not attempt to attach NS_RETURNS_INNER_POINTER to
- // the getter method as it ends up on the property itself which we don't want
- // to do unless -objcmt-returns-innerpointer-property option is on.
- if (!PropertyInferred ||
- (ASTMigrateActions & FrontendOptions::ObjCMT_ReturnsInnerPointerProperty))
- if (ASTMigrateActions & FrontendOptions::ObjCMT_Annotation)
- migrateNsReturnsInnerPointer(Ctx, Method);
- }
- if (!(ASTMigrateActions & FrontendOptions::ObjCMT_ReturnsInnerPointerProperty))
- return;
-
- for (auto *Prop : D->instance_properties()) {
- if ((ASTMigrateActions & FrontendOptions::ObjCMT_Annotation) &&
- !Prop->isDeprecated())
- migratePropertyNsReturnsInnerPointer(Ctx, Prop);
- }
-}
-
-static bool
-ClassImplementsAllMethodsAndProperties(ASTContext &Ctx,
- const ObjCImplementationDecl *ImpDecl,
- const ObjCInterfaceDecl *IDecl,
- ObjCProtocolDecl *Protocol) {
- // In auto-synthesis, protocol properties are not synthesized. So,
- // a conforming protocol must have its required properties declared
- // in class interface.
- bool HasAtleastOneRequiredProperty = false;
- if (const ObjCProtocolDecl *PDecl = Protocol->getDefinition())
- for (const auto *Property : PDecl->instance_properties()) {
- if (Property->getPropertyImplementation() == ObjCPropertyDecl::Optional)
- continue;
- HasAtleastOneRequiredProperty = true;
- DeclContext::lookup_result R = IDecl->lookup(Property->getDeclName());
- if (R.empty()) {
- // Relax the rule and look into class's implementation for a synthesize
- // or dynamic declaration. Class is implementing a property coming from
- // another protocol. This still makes the target protocol as conforming.
- if (!ImpDecl->FindPropertyImplDecl(
- Property->getDeclName().getAsIdentifierInfo(),
- Property->getQueryKind()))
- return false;
- } else if (auto *ClassProperty = R.find_first<ObjCPropertyDecl>()) {
- if ((ClassProperty->getPropertyAttributes() !=
- Property->getPropertyAttributes()) ||
- !Ctx.hasSameType(ClassProperty->getType(), Property->getType()))
- return false;
- } else
- return false;
- }
-
- // At this point, all required properties in this protocol conform to those
- // declared in the class.
- // Check that class implements the required methods of the protocol too.
- bool HasAtleastOneRequiredMethod = false;
- if (const ObjCProtocolDecl *PDecl = Protocol->getDefinition()) {
- if (PDecl->meth_begin() == PDecl->meth_end())
- return HasAtleastOneRequiredProperty;
- for (const auto *MD : PDecl->methods()) {
- if (MD->isImplicit())
- continue;
- if (MD->getImplementationControl() == ObjCImplementationControl::Optional)
- continue;
- DeclContext::lookup_result R = ImpDecl->lookup(MD->getDeclName());
- if (R.empty())
- return false;
- bool match = false;
- HasAtleastOneRequiredMethod = true;
- for (NamedDecl *ND : R)
- if (ObjCMethodDecl *ImpMD = dyn_cast<ObjCMethodDecl>(ND))
- if (Ctx.ObjCMethodsAreEqual(MD, ImpMD)) {
- match = true;
- break;
- }
- if (!match)
- return false;
- }
- }
- return HasAtleastOneRequiredProperty || HasAtleastOneRequiredMethod;
-}
-
-static bool rewriteToObjCInterfaceDecl(const ObjCInterfaceDecl *IDecl,
- llvm::SmallVectorImpl<ObjCProtocolDecl*> &ConformingProtocols,
- const NSAPI &NS, edit::Commit &commit) {
- const ObjCList<ObjCProtocolDecl> &Protocols = IDecl->getReferencedProtocols();
- std::string ClassString;
- SourceLocation EndLoc =
- IDecl->getSuperClass() ? IDecl->getSuperClassLoc() : IDecl->getLocation();
-
- if (Protocols.empty()) {
- ClassString = '<';
- for (unsigned i = 0, e = ConformingProtocols.size(); i != e; i++) {
- ClassString += ConformingProtocols[i]->getNameAsString();
- if (i != (e-1))
- ClassString += ", ";
- }
- ClassString += "> ";
- }
- else {
- ClassString = ", ";
- for (unsigned i = 0, e = ConformingProtocols.size(); i != e; i++) {
- ClassString += ConformingProtocols[i]->getNameAsString();
- if (i != (e-1))
- ClassString += ", ";
- }
- ObjCInterfaceDecl::protocol_loc_iterator PL = IDecl->protocol_loc_end() - 1;
- EndLoc = *PL;
- }
-
- commit.insertAfterToken(EndLoc, ClassString);
- return true;
-}
-
-static StringRef GetUnsignedName(StringRef NSIntegerName) {
- StringRef UnsignedName = llvm::StringSwitch<StringRef>(NSIntegerName)
- .Case("int8_t", "uint8_t")
- .Case("int16_t", "uint16_t")
- .Case("int32_t", "uint32_t")
- .Case("NSInteger", "NSUInteger")
- .Case("int64_t", "uint64_t")
- .Default(NSIntegerName);
- return UnsignedName;
-}
-
-static bool rewriteToNSEnumDecl(const EnumDecl *EnumDcl,
- const TypedefDecl *TypedefDcl,
- const NSAPI &NS, edit::Commit &commit,
- StringRef NSIntegerName,
- bool NSOptions) {
- std::string ClassString;
- if (NSOptions) {
- ClassString = "typedef NS_OPTIONS(";
- ClassString += GetUnsignedName(NSIntegerName);
- }
- else {
- ClassString = "typedef NS_ENUM(";
- ClassString += NSIntegerName;
- }
- ClassString += ", ";
-
- ClassString += TypedefDcl->getIdentifier()->getName();
- ClassString += ')';
- SourceRange R(EnumDcl->getBeginLoc(), EnumDcl->getBeginLoc());
- commit.replace(R, ClassString);
- SourceLocation EndOfEnumDclLoc = EnumDcl->getEndLoc();
- EndOfEnumDclLoc = trans::findSemiAfterLocation(EndOfEnumDclLoc,
- NS.getASTContext(), /*IsDecl*/true);
- if (EndOfEnumDclLoc.isValid()) {
- SourceRange EnumDclRange(EnumDcl->getBeginLoc(), EndOfEnumDclLoc);
- commit.insertFromRange(TypedefDcl->getBeginLoc(), EnumDclRange);
- }
- else
- return false;
-
- SourceLocation EndTypedefDclLoc = TypedefDcl->getEndLoc();
- EndTypedefDclLoc = trans::findSemiAfterLocation(EndTypedefDclLoc,
- NS.getASTContext(), /*IsDecl*/true);
- if (EndTypedefDclLoc.isValid()) {
- SourceRange TDRange(TypedefDcl->getBeginLoc(), EndTypedefDclLoc);
- commit.remove(TDRange);
- }
- else
- return false;
-
- EndOfEnumDclLoc =
- trans::findLocationAfterSemi(EnumDcl->getEndLoc(), NS.getASTContext(),
- /*IsDecl*/ true);
- if (EndOfEnumDclLoc.isValid()) {
- SourceLocation BeginOfEnumDclLoc = EnumDcl->getBeginLoc();
- // FIXME. This assumes that enum decl; is immediately preceded by eoln.
- // It is trying to remove the enum decl. lines entirely.
- BeginOfEnumDclLoc = BeginOfEnumDclLoc.getLocWithOffset(-1);
- commit.remove(SourceRange(BeginOfEnumDclLoc, EndOfEnumDclLoc));
- return true;
- }
- return false;
-}
-
-static void rewriteToNSMacroDecl(ASTContext &Ctx,
- const EnumDecl *EnumDcl,
- const TypedefDecl *TypedefDcl,
- const NSAPI &NS, edit::Commit &commit,
- bool IsNSIntegerType) {
- QualType DesignatedEnumType = EnumDcl->getIntegerType();
- assert(!DesignatedEnumType.isNull()
- && "rewriteToNSMacroDecl - underlying enum type is null");
-
- PrintingPolicy Policy(Ctx.getPrintingPolicy());
- std::string TypeString = DesignatedEnumType.getAsString(Policy);
- std::string ClassString = IsNSIntegerType ? "NS_ENUM(" : "NS_OPTIONS(";
- ClassString += TypeString;
- ClassString += ", ";
-
- ClassString += TypedefDcl->getIdentifier()->getName();
- ClassString += ") ";
- SourceLocation EndLoc = EnumDcl->getBraceRange().getBegin();
- if (EndLoc.isInvalid())
- return;
- CharSourceRange R =
- CharSourceRange::getCharRange(EnumDcl->getBeginLoc(), EndLoc);
- commit.replace(R, ClassString);
- // This is to remove spaces between '}' and typedef name.
- SourceLocation StartTypedefLoc = EnumDcl->getEndLoc();
- StartTypedefLoc = StartTypedefLoc.getLocWithOffset(+1);
- SourceLocation EndTypedefLoc = TypedefDcl->getEndLoc();
-
- commit.remove(SourceRange(StartTypedefLoc, EndTypedefLoc));
-}
-
-static bool UseNSOptionsMacro(Preprocessor &PP, ASTContext &Ctx,
- const EnumDecl *EnumDcl) {
- bool PowerOfTwo = true;
- bool AllHexdecimalEnumerator = true;
- uint64_t MaxPowerOfTwoVal = 0;
- for (auto *Enumerator : EnumDcl->enumerators()) {
- const Expr *InitExpr = Enumerator->getInitExpr();
- if (!InitExpr) {
- PowerOfTwo = false;
- AllHexdecimalEnumerator = false;
- continue;
- }
- InitExpr = InitExpr->IgnoreParenCasts();
- if (const BinaryOperator *BO = dyn_cast<BinaryOperator>(InitExpr))
- if (BO->isShiftOp() || BO->isBitwiseOp())
- return true;
-
- uint64_t EnumVal = Enumerator->getInitVal().getZExtValue();
- if (PowerOfTwo && EnumVal) {
- if (!llvm::isPowerOf2_64(EnumVal))
- PowerOfTwo = false;
- else if (EnumVal > MaxPowerOfTwoVal)
- MaxPowerOfTwoVal = EnumVal;
- }
- if (AllHexdecimalEnumerator && EnumVal) {
- bool FoundHexdecimalEnumerator = false;
- SourceLocation EndLoc = Enumerator->getEndLoc();
- Token Tok;
- if (!PP.getRawToken(EndLoc, Tok, /*IgnoreWhiteSpace=*/true))
- if (Tok.isLiteral() && Tok.getLength() > 2) {
- if (const char *StringLit = Tok.getLiteralData())
- FoundHexdecimalEnumerator =
- (StringLit[0] == '0' && (toLowercase(StringLit[1]) == 'x'));
- }
- if (!FoundHexdecimalEnumerator)
- AllHexdecimalEnumerator = false;
- }
- }
- return AllHexdecimalEnumerator || (PowerOfTwo && (MaxPowerOfTwoVal > 2));
-}
-
-void ObjCMigrateASTConsumer::migrateProtocolConformance(ASTContext &Ctx,
- const ObjCImplementationDecl *ImpDecl) {
- const ObjCInterfaceDecl *IDecl = ImpDecl->getClassInterface();
- if (!IDecl || ObjCProtocolDecls.empty() || IDecl->isDeprecated())
- return;
- // Find all implicit conforming protocols for this class
- // and make them explicit.
- llvm::SmallPtrSet<ObjCProtocolDecl *, 8> ExplicitProtocols;
- Ctx.CollectInheritedProtocols(IDecl, ExplicitProtocols);
- llvm::SmallVector<ObjCProtocolDecl *, 8> PotentialImplicitProtocols;
-
- for (ObjCProtocolDecl *ProtDecl : ObjCProtocolDecls)
- if (!ExplicitProtocols.count(ProtDecl))
- PotentialImplicitProtocols.push_back(ProtDecl);
-
- if (PotentialImplicitProtocols.empty())
- return;
-
- // go through list of non-optional methods and properties in each protocol
- // in the PotentialImplicitProtocols list. If class implements every one of the
- // methods and properties, then this class conforms to this protocol.
- llvm::SmallVector<ObjCProtocolDecl*, 8> ConformingProtocols;
- for (unsigned i = 0, e = PotentialImplicitProtocols.size(); i != e; i++)
- if (ClassImplementsAllMethodsAndProperties(Ctx, ImpDecl, IDecl,
- PotentialImplicitProtocols[i]))
- ConformingProtocols.push_back(PotentialImplicitProtocols[i]);
-
- if (ConformingProtocols.empty())
- return;
-
- // Further reduce number of conforming protocols. If protocol P1 is in the list
- // protocol P2 (P2<P1>), No need to include P1.
- llvm::SmallVector<ObjCProtocolDecl*, 8> MinimalConformingProtocols;
- for (unsigned i = 0, e = ConformingProtocols.size(); i != e; i++) {
- bool DropIt = false;
- ObjCProtocolDecl *TargetPDecl = ConformingProtocols[i];
- for (unsigned i1 = 0, e1 = ConformingProtocols.size(); i1 != e1; i1++) {
- ObjCProtocolDecl *PDecl = ConformingProtocols[i1];
- if (PDecl == TargetPDecl)
- continue;
- if (PDecl->lookupProtocolNamed(
- TargetPDecl->getDeclName().getAsIdentifierInfo())) {
- DropIt = true;
- break;
- }
- }
- if (!DropIt)
- MinimalConformingProtocols.push_back(TargetPDecl);
- }
- if (MinimalConformingProtocols.empty())
- return;
- edit::Commit commit(*Editor);
- rewriteToObjCInterfaceDecl(IDecl, MinimalConformingProtocols,
- *NSAPIObj, commit);
- Editor->commit(commit);
-}
-
-void ObjCMigrateASTConsumer::CacheObjCNSIntegerTypedefed(
- const TypedefDecl *TypedefDcl) {
-
- QualType qt = TypedefDcl->getTypeSourceInfo()->getType();
- if (NSAPIObj->isObjCNSIntegerType(qt))
- NSIntegerTypedefed = TypedefDcl;
- else if (NSAPIObj->isObjCNSUIntegerType(qt))
- NSUIntegerTypedefed = TypedefDcl;
-}
-
-bool ObjCMigrateASTConsumer::migrateNSEnumDecl(ASTContext &Ctx,
- const EnumDecl *EnumDcl,
- const TypedefDecl *TypedefDcl) {
- if (!EnumDcl->isCompleteDefinition() || EnumDcl->getIdentifier() ||
- EnumDcl->isDeprecated())
- return false;
- if (!TypedefDcl) {
- if (NSIntegerTypedefed) {
- TypedefDcl = NSIntegerTypedefed;
- NSIntegerTypedefed = nullptr;
- }
- else if (NSUIntegerTypedefed) {
- TypedefDcl = NSUIntegerTypedefed;
- NSUIntegerTypedefed = nullptr;
- }
- else
- return false;
- FileID FileIdOfTypedefDcl =
- PP.getSourceManager().getFileID(TypedefDcl->getLocation());
- FileID FileIdOfEnumDcl =
- PP.getSourceManager().getFileID(EnumDcl->getLocation());
- if (FileIdOfTypedefDcl != FileIdOfEnumDcl)
- return false;
- }
- if (TypedefDcl->isDeprecated())
- return false;
-
- QualType qt = TypedefDcl->getTypeSourceInfo()->getType();
- StringRef NSIntegerName = NSAPIObj->GetNSIntegralKind(qt);
-
- if (NSIntegerName.empty()) {
- // Also check for typedef enum {...} TD;
- if (const EnumType *EnumTy = qt->getAs<EnumType>()) {
- if (EnumTy->getDecl() == EnumDcl) {
- bool NSOptions = UseNSOptionsMacro(PP, Ctx, EnumDcl);
- if (!InsertFoundation(Ctx, TypedefDcl->getBeginLoc()))
- return false;
- edit::Commit commit(*Editor);
- rewriteToNSMacroDecl(Ctx, EnumDcl, TypedefDcl, *NSAPIObj, commit, !NSOptions);
- Editor->commit(commit);
- return true;
- }
- }
- return false;
- }
-
- // We may still use NS_OPTIONS based on what we find in the enumertor list.
- bool NSOptions = UseNSOptionsMacro(PP, Ctx, EnumDcl);
- if (!InsertFoundation(Ctx, TypedefDcl->getBeginLoc()))
- return false;
- edit::Commit commit(*Editor);
- bool Res = rewriteToNSEnumDecl(EnumDcl, TypedefDcl, *NSAPIObj,
- commit, NSIntegerName, NSOptions);
- Editor->commit(commit);
- return Res;
-}
-
-static void ReplaceWithInstancetype(ASTContext &Ctx,
- const ObjCMigrateASTConsumer &ASTC,
- ObjCMethodDecl *OM) {
- if (OM->getReturnType() == Ctx.getObjCInstanceType())
- return; // already has instancetype.
-
- SourceRange R;
- std::string ClassString;
- if (TypeSourceInfo *TSInfo = OM->getReturnTypeSourceInfo()) {
- TypeLoc TL = TSInfo->getTypeLoc();
- R = SourceRange(TL.getBeginLoc(), TL.getEndLoc());
- ClassString = "instancetype";
- }
- else {
- R = SourceRange(OM->getBeginLoc(), OM->getBeginLoc());
- ClassString = OM->isInstanceMethod() ? '-' : '+';
- ClassString += " (instancetype)";
- }
- edit::Commit commit(*ASTC.Editor);
- commit.replace(R, ClassString);
- ASTC.Editor->commit(commit);
-}
-
-static void ReplaceWithClasstype(const ObjCMigrateASTConsumer &ASTC,
- ObjCMethodDecl *OM) {
- ObjCInterfaceDecl *IDecl = OM->getClassInterface();
- SourceRange R;
- std::string ClassString;
- if (TypeSourceInfo *TSInfo = OM->getReturnTypeSourceInfo()) {
- TypeLoc TL = TSInfo->getTypeLoc();
- R = SourceRange(TL.getBeginLoc(), TL.getEndLoc()); {
- ClassString = std::string(IDecl->getName());
- ClassString += "*";
- }
- }
- else {
- R = SourceRange(OM->getBeginLoc(), OM->getBeginLoc());
- ClassString = "+ (";
- ClassString += IDecl->getName(); ClassString += "*)";
- }
- edit::Commit commit(*ASTC.Editor);
- commit.replace(R, ClassString);
- ASTC.Editor->commit(commit);
-}
-
-void ObjCMigrateASTConsumer::migrateMethodInstanceType(ASTContext &Ctx,
- ObjCContainerDecl *CDecl,
- ObjCMethodDecl *OM) {
- ObjCInstanceTypeFamily OIT_Family =
- Selector::getInstTypeMethodFamily(OM->getSelector());
-
- std::string ClassName;
- switch (OIT_Family) {
- case OIT_None:
- migrateFactoryMethod(Ctx, CDecl, OM);
- return;
- case OIT_Array:
- ClassName = "NSArray";
- break;
- case OIT_Dictionary:
- ClassName = "NSDictionary";
- break;
- case OIT_Singleton:
- migrateFactoryMethod(Ctx, CDecl, OM, OIT_Singleton);
- return;
- case OIT_Init:
- if (OM->getReturnType()->isObjCIdType())
- ReplaceWithInstancetype(Ctx, *this, OM);
- return;
- case OIT_ReturnsSelf:
- migrateFactoryMethod(Ctx, CDecl, OM, OIT_ReturnsSelf);
- return;
- }
- if (!OM->getReturnType()->isObjCIdType())
- return;
-
- ObjCInterfaceDecl *IDecl = dyn_cast<ObjCInterfaceDecl>(CDecl);
- if (!IDecl) {
- if (ObjCCategoryDecl *CatDecl = dyn_cast<ObjCCategoryDecl>(CDecl))
- IDecl = CatDecl->getClassInterface();
- else if (ObjCImplDecl *ImpDecl = dyn_cast<ObjCImplDecl>(CDecl))
- IDecl = ImpDecl->getClassInterface();
- }
- if (!IDecl ||
- !IDecl->lookupInheritedClass(&Ctx.Idents.get(ClassName))) {
- migrateFactoryMethod(Ctx, CDecl, OM);
- return;
- }
- ReplaceWithInstancetype(Ctx, *this, OM);
-}
-
-static bool TypeIsInnerPointer(QualType T) {
- if (!T->isAnyPointerType())
- return false;
- if (T->isObjCObjectPointerType() || T->isObjCBuiltinType() ||
- T->isBlockPointerType() || T->isFunctionPointerType() ||
- ento::coreFoundation::isCFObjectRef(T))
- return false;
- // Also, typedef-of-pointer-to-incomplete-struct is something that we assume
- // is not an innter pointer type.
- QualType OrigT = T;
- while (const auto *TD = T->getAs<TypedefType>())
- T = TD->getDecl()->getUnderlyingType();
- if (OrigT == T || !T->isPointerType())
- return true;
- const PointerType* PT = T->getAs<PointerType>();
- QualType UPointeeT = PT->getPointeeType().getUnqualifiedType();
- if (UPointeeT->isRecordType()) {
- const RecordType *RecordTy = UPointeeT->getAs<RecordType>();
- if (!RecordTy->getDecl()->isCompleteDefinition())
- return false;
- }
- return true;
-}
-
-/// Check whether the two versions match.
-static bool versionsMatch(const VersionTuple &X, const VersionTuple &Y) {
- return (X == Y);
-}
-
-/// AvailabilityAttrsMatch - This routine checks that if comparing two
-/// availability attributes, all their components match. It returns
-/// true, if not dealing with availability or when all components of
-/// availability attributes match. This routine is only called when
-/// the attributes are of the same kind.
-static bool AvailabilityAttrsMatch(Attr *At1, Attr *At2) {
- const AvailabilityAttr *AA1 = dyn_cast<AvailabilityAttr>(At1);
- if (!AA1)
- return true;
- const AvailabilityAttr *AA2 = cast<AvailabilityAttr>(At2);
-
- VersionTuple Introduced1 = AA1->getIntroduced();
- VersionTuple Deprecated1 = AA1->getDeprecated();
- VersionTuple Obsoleted1 = AA1->getObsoleted();
- bool IsUnavailable1 = AA1->getUnavailable();
- VersionTuple Introduced2 = AA2->getIntroduced();
- VersionTuple Deprecated2 = AA2->getDeprecated();
- VersionTuple Obsoleted2 = AA2->getObsoleted();
- bool IsUnavailable2 = AA2->getUnavailable();
- return (versionsMatch(Introduced1, Introduced2) &&
- versionsMatch(Deprecated1, Deprecated2) &&
- versionsMatch(Obsoleted1, Obsoleted2) &&
- IsUnavailable1 == IsUnavailable2);
-}
-
-static bool MatchTwoAttributeLists(const AttrVec &Attrs1, const AttrVec &Attrs2,
- bool &AvailabilityArgsMatch) {
- // This list is very small, so this need not be optimized.
- for (unsigned i = 0, e = Attrs1.size(); i != e; i++) {
- bool match = false;
- for (unsigned j = 0, f = Attrs2.size(); j != f; j++) {
- // Matching attribute kind only. Except for Availability attributes,
- // we are not getting into details of the attributes. For all practical purposes
- // this is sufficient.
- if (Attrs1[i]->getKind() == Attrs2[j]->getKind()) {
- if (AvailabilityArgsMatch)
- AvailabilityArgsMatch = AvailabilityAttrsMatch(Attrs1[i], Attrs2[j]);
- match = true;
- break;
- }
- }
- if (!match)
- return false;
- }
- return true;
-}
-
-/// AttributesMatch - This routine checks list of attributes for two
-/// decls. It returns false, if there is a mismatch in kind of
-/// attributes seen in the decls. It returns true if the two decls
-/// have list of same kind of attributes. Furthermore, when there
-/// are availability attributes in the two decls, it sets the
-/// AvailabilityArgsMatch to false if availability attributes have
-/// different versions, etc.
-static bool AttributesMatch(const Decl *Decl1, const Decl *Decl2,
- bool &AvailabilityArgsMatch) {
- if (!Decl1->hasAttrs() || !Decl2->hasAttrs()) {
- AvailabilityArgsMatch = (Decl1->hasAttrs() == Decl2->hasAttrs());
- return true;
- }
- AvailabilityArgsMatch = true;
- const AttrVec &Attrs1 = Decl1->getAttrs();
- const AttrVec &Attrs2 = Decl2->getAttrs();
- bool match = MatchTwoAttributeLists(Attrs1, Attrs2, AvailabilityArgsMatch);
- if (match && (Attrs2.size() > Attrs1.size()))
- return MatchTwoAttributeLists(Attrs2, Attrs1, AvailabilityArgsMatch);
- return match;
-}
-
-static bool IsValidIdentifier(ASTContext &Ctx,
- const char *Name) {
- if (!isAsciiIdentifierStart(Name[0]))
- return false;
- std::string NameString = Name;
- NameString[0] = toLowercase(NameString[0]);
- const IdentifierInfo *II = &Ctx.Idents.get(NameString);
- return II->getTokenID() == tok::identifier;
-}
-
-bool ObjCMigrateASTConsumer::migrateProperty(ASTContext &Ctx,
- ObjCContainerDecl *D,
- ObjCMethodDecl *Method) {
- if (Method->isPropertyAccessor() || !Method->isInstanceMethod() ||
- Method->param_size() != 0)
- return false;
- // Is this method candidate to be a getter?
- QualType GRT = Method->getReturnType();
- if (GRT->isVoidType())
- return false;
-
- Selector GetterSelector = Method->getSelector();
- ObjCInstanceTypeFamily OIT_Family =
- Selector::getInstTypeMethodFamily(GetterSelector);
-
- if (OIT_Family != OIT_None)
- return false;
-
- const IdentifierInfo *getterName = GetterSelector.getIdentifierInfoForSlot(0);
- Selector SetterSelector =
- SelectorTable::constructSetterSelector(PP.getIdentifierTable(),
- PP.getSelectorTable(),
- getterName);
- ObjCMethodDecl *SetterMethod = D->getInstanceMethod(SetterSelector);
- unsigned LengthOfPrefix = 0;
- if (!SetterMethod) {
- // try a different naming convention for getter: isXxxxx
- StringRef getterNameString = getterName->getName();
- bool IsPrefix = getterNameString.starts_with("is");
- // Note that we don't want to change an isXXX method of retainable object
- // type to property (readonly or otherwise).
- if (IsPrefix && GRT->isObjCRetainableType())
- return false;
- if (IsPrefix || getterNameString.starts_with("get")) {
- LengthOfPrefix = (IsPrefix ? 2 : 3);
- const char *CGetterName = getterNameString.data() + LengthOfPrefix;
- // Make sure that first character after "is" or "get" prefix can
- // start an identifier.
- if (!IsValidIdentifier(Ctx, CGetterName))
- return false;
- if (CGetterName[0] && isUppercase(CGetterName[0])) {
- getterName = &Ctx.Idents.get(CGetterName);
- SetterSelector =
- SelectorTable::constructSetterSelector(PP.getIdentifierTable(),
- PP.getSelectorTable(),
- getterName);
- SetterMethod = D->getInstanceMethod(SetterSelector);
- }
- }
- }
-
- if (SetterMethod) {
- if ((ASTMigrateActions & FrontendOptions::ObjCMT_ReadwriteProperty) == 0)
- return false;
- bool AvailabilityArgsMatch;
- if (SetterMethod->isDeprecated() ||
- !AttributesMatch(Method, SetterMethod, AvailabilityArgsMatch))
- return false;
-
- // Is this a valid setter, matching the target getter?
- QualType SRT = SetterMethod->getReturnType();
- if (!SRT->isVoidType())
- return false;
- const ParmVarDecl *argDecl = *SetterMethod->param_begin();
- QualType ArgType = argDecl->getType();
- if (!Ctx.hasSameUnqualifiedType(ArgType, GRT))
- return false;
- edit::Commit commit(*Editor);
- rewriteToObjCProperty(Method, SetterMethod, *NSAPIObj, commit,
- LengthOfPrefix,
- (ASTMigrateActions &
- FrontendOptions::ObjCMT_AtomicProperty) != 0,
- (ASTMigrateActions &
- FrontendOptions::ObjCMT_NsAtomicIOSOnlyProperty) != 0,
- AvailabilityArgsMatch);
- Editor->commit(commit);
- return true;
- }
- else if (ASTMigrateActions & FrontendOptions::ObjCMT_ReadonlyProperty) {
- // Try a non-void method with no argument (and no setter or property of same name
- // as a 'readonly' property.
- edit::Commit commit(*Editor);
- rewriteToObjCProperty(Method, nullptr /*SetterMethod*/, *NSAPIObj, commit,
- LengthOfPrefix,
- (ASTMigrateActions &
- FrontendOptions::ObjCMT_AtomicProperty) != 0,
- (ASTMigrateActions &
- FrontendOptions::ObjCMT_NsAtomicIOSOnlyProperty) != 0,
- /*AvailabilityArgsMatch*/false);
- Editor->commit(commit);
- return true;
- }
- return false;
-}
-
-void ObjCMigrateASTConsumer::migrateNsReturnsInnerPointer(ASTContext &Ctx,
- ObjCMethodDecl *OM) {
- if (OM->isImplicit() ||
- !OM->isInstanceMethod() ||
- OM->hasAttr<ObjCReturnsInnerPointerAttr>())
- return;
-
- QualType RT = OM->getReturnType();
- if (!TypeIsInnerPointer(RT) ||
- !NSAPIObj->isMacroDefined("NS_RETURNS_INNER_POINTER"))
- return;
-
- edit::Commit commit(*Editor);
- commit.insertBefore(OM->getEndLoc(), " NS_RETURNS_INNER_POINTER");
- Editor->commit(commit);
-}
-
-void ObjCMigrateASTConsumer::migratePropertyNsReturnsInnerPointer(ASTContext &Ctx,
- ObjCPropertyDecl *P) {
- QualType T = P->getType();
-
- if (!TypeIsInnerPointer(T) ||
- !NSAPIObj->isMacroDefined("NS_RETURNS_INNER_POINTER"))
- return;
- edit::Commit commit(*Editor);
- commit.insertBefore(P->getEndLoc(), " NS_RETURNS_INNER_POINTER ");
- Editor->commit(commit);
-}
-
-void ObjCMigrateASTConsumer::migrateAllMethodInstaceType(ASTContext &Ctx,
- ObjCContainerDecl *CDecl) {
- if (CDecl->isDeprecated() || IsCategoryNameWithDeprecatedSuffix(CDecl))
- return;
-
- // migrate methods which can have instancetype as their result type.
- for (auto *Method : CDecl->methods()) {
- if (Method->isDeprecated())
- continue;
- migrateMethodInstanceType(Ctx, CDecl, Method);
- }
-}
-
-void ObjCMigrateASTConsumer::migrateFactoryMethod(ASTContext &Ctx,
- ObjCContainerDecl *CDecl,
- ObjCMethodDecl *OM,
- ObjCInstanceTypeFamily OIT_Family) {
- if (OM->isInstanceMethod() ||
- OM->getReturnType() == Ctx.getObjCInstanceType() ||
- !OM->getReturnType()->isObjCIdType())
- return;
-
- // Candidate factory methods are + (id) NaMeXXX : ... which belong to a class
- // NSYYYNamE with matching names be at least 3 characters long.
- ObjCInterfaceDecl *IDecl = dyn_cast<ObjCInterfaceDecl>(CDecl);
- if (!IDecl) {
- if (ObjCCategoryDecl *CatDecl = dyn_cast<ObjCCategoryDecl>(CDecl))
- IDecl = CatDecl->getClassInterface();
- else if (ObjCImplDecl *ImpDecl = dyn_cast<ObjCImplDecl>(CDecl))
- IDecl = ImpDecl->getClassInterface();
- }
- if (!IDecl)
- return;
-
- std::string StringClassName = std::string(IDecl->getName());
- StringRef LoweredClassName(StringClassName);
- std::string StringLoweredClassName = LoweredClassName.lower();
- LoweredClassName = StringLoweredClassName;
-
- const IdentifierInfo *MethodIdName =
- OM->getSelector().getIdentifierInfoForSlot(0);
- // Handle method with no name at its first selector slot; e.g. + (id):(int)x.
- if (!MethodIdName)
- return;
-
- std::string MethodName = std::string(MethodIdName->getName());
- if (OIT_Family == OIT_Singleton || OIT_Family == OIT_ReturnsSelf) {
- StringRef STRefMethodName(MethodName);
- size_t len = 0;
- if (STRefMethodName.starts_with("standard"))
- len = strlen("standard");
- else if (STRefMethodName.starts_with("shared"))
- len = strlen("shared");
- else if (STRefMethodName.starts_with("default"))
- len = strlen("default");
- else
- return;
- MethodName = std::string(STRefMethodName.substr(len));
- }
- std::string MethodNameSubStr = MethodName.substr(0, 3);
- StringRef MethodNamePrefix(MethodNameSubStr);
- std::string StringLoweredMethodNamePrefix = MethodNamePrefix.lower();
- MethodNamePrefix = StringLoweredMethodNamePrefix;
- size_t Ix = LoweredClassName.rfind(MethodNamePrefix);
- if (Ix == StringRef::npos)
- return;
- std::string ClassNamePostfix = std::string(LoweredClassName.substr(Ix));
- StringRef LoweredMethodName(MethodName);
- std::string StringLoweredMethodName = LoweredMethodName.lower();
- LoweredMethodName = StringLoweredMethodName;
- if (!LoweredMethodName.starts_with(ClassNamePostfix))
- return;
- if (OIT_Family == OIT_ReturnsSelf)
- ReplaceWithClasstype(*this, OM);
- else
- ReplaceWithInstancetype(Ctx, *this, OM);
-}
-
-static bool IsVoidStarType(QualType Ty) {
- if (!Ty->isPointerType())
- return false;
-
- // Is the type void*?
- const PointerType* PT = Ty->castAs<PointerType>();
- if (PT->getPointeeType().getUnqualifiedType()->isVoidType())
- return true;
- return IsVoidStarType(PT->getPointeeType());
-}
-
-/// AuditedType - This routine audits the type AT and returns false if it is one of known
-/// CF object types or of the "void *" variety. It returns true if we don't care about the type
-/// such as a non-pointer or pointers which have no ownership issues (such as "int *").
-static bool AuditedType (QualType AT) {
- if (!AT->isAnyPointerType() && !AT->isBlockPointerType())
- return true;
- // FIXME. There isn't much we can say about CF pointer type; or is there?
- if (ento::coreFoundation::isCFObjectRef(AT) ||
- IsVoidStarType(AT) ||
- // If an ObjC object is type, assuming that it is not a CF function and
- // that it is an un-audited function.
- AT->isObjCObjectPointerType() || AT->isObjCBuiltinType())
- return false;
- // All other pointers are assumed audited as harmless.
- return true;
-}
-
-void ObjCMigrateASTConsumer::AnnotateImplicitBridging(ASTContext &Ctx) {
- if (CFFunctionIBCandidates.empty())
- return;
- if (!NSAPIObj->isMacroDefined("CF_IMPLICIT_BRIDGING_ENABLED")) {
- CFFunctionIBCandidates.clear();
- FileId = FileID();
- return;
- }
- // Insert CF_IMPLICIT_BRIDGING_ENABLE/CF_IMPLICIT_BRIDGING_DISABLED
- const Decl *FirstFD = CFFunctionIBCandidates[0];
- const Decl *LastFD =
- CFFunctionIBCandidates[CFFunctionIBCandidates.size()-1];
- const char *PragmaString = "\nCF_IMPLICIT_BRIDGING_ENABLED\n\n";
- edit::Commit commit(*Editor);
- commit.insertBefore(FirstFD->getBeginLoc(), PragmaString);
- PragmaString = "\n\nCF_IMPLICIT_BRIDGING_DISABLED\n";
- SourceLocation EndLoc = LastFD->getEndLoc();
- // get location just past end of function location.
- EndLoc = PP.getLocForEndOfToken(EndLoc);
- if (isa<FunctionDecl>(LastFD)) {
- // For Methods, EndLoc points to the ending semcolon. So,
- // not of these extra work is needed.
- Token Tok;
- // get locaiton of token that comes after end of function.
- bool Failed = PP.getRawToken(EndLoc, Tok, /*IgnoreWhiteSpace=*/true);
- if (!Failed)
- EndLoc = Tok.getLocation();
- }
- commit.insertAfterToken(EndLoc, PragmaString);
- Editor->commit(commit);
- FileId = FileID();
- CFFunctionIBCandidates.clear();
-}
-
-void ObjCMigrateASTConsumer::migrateCFAnnotation(ASTContext &Ctx, const Decl *Decl) {
- if (Decl->isDeprecated())
- return;
-
- if (Decl->hasAttr<CFAuditedTransferAttr>()) {
- assert(CFFunctionIBCandidates.empty() &&
- "Cannot have audited functions/methods inside user "
- "provided CF_IMPLICIT_BRIDGING_ENABLE");
- return;
- }
-
- // Finction must be annotated first.
- if (const FunctionDecl *FuncDecl = dyn_cast<FunctionDecl>(Decl)) {
- CF_BRIDGING_KIND AuditKind = migrateAddFunctionAnnotation(Ctx, FuncDecl);
- if (AuditKind == CF_BRIDGING_ENABLE) {
- CFFunctionIBCandidates.push_back(Decl);
- if (FileId.isInvalid())
- FileId = PP.getSourceManager().getFileID(Decl->getLocation());
- }
- else if (AuditKind == CF_BRIDGING_MAY_INCLUDE) {
- if (!CFFunctionIBCandidates.empty()) {
- CFFunctionIBCandidates.push_back(Decl);
- if (FileId.isInvalid())
- FileId = PP.getSourceManager().getFileID(Decl->getLocation());
- }
- }
- else
- AnnotateImplicitBridging(Ctx);
- }
- else {
- migrateAddMethodAnnotation(Ctx, cast<ObjCMethodDecl>(Decl));
- AnnotateImplicitBridging(Ctx);
- }
-}
-
-void ObjCMigrateASTConsumer::AddCFAnnotations(ASTContext &Ctx,
- const RetainSummary *RS,
- const FunctionDecl *FuncDecl,
- bool ResultAnnotated) {
- // Annotate function.
- if (!ResultAnnotated) {
- RetEffect Ret = RS->getRetEffect();
- const char *AnnotationString = nullptr;
- if (Ret.getObjKind() == ObjKind::CF) {
- if (Ret.isOwned() && NSAPIObj->isMacroDefined("CF_RETURNS_RETAINED"))
- AnnotationString = " CF_RETURNS_RETAINED";
- else if (Ret.notOwned() &&
- NSAPIObj->isMacroDefined("CF_RETURNS_NOT_RETAINED"))
- AnnotationString = " CF_RETURNS_NOT_RETAINED";
- }
- else if (Ret.getObjKind() == ObjKind::ObjC) {
- if (Ret.isOwned() && NSAPIObj->isMacroDefined("NS_RETURNS_RETAINED"))
- AnnotationString = " NS_RETURNS_RETAINED";
- }
-
- if (AnnotationString) {
- edit::Commit commit(*Editor);
- commit.insertAfterToken(FuncDecl->getEndLoc(), AnnotationString);
- Editor->commit(commit);
- }
- }
- unsigned i = 0;
- for (FunctionDecl::param_const_iterator pi = FuncDecl->param_begin(),
- pe = FuncDecl->param_end(); pi != pe; ++pi, ++i) {
- const ParmVarDecl *pd = *pi;
- ArgEffect AE = RS->getArg(i);
- if (AE.getKind() == DecRef && AE.getObjKind() == ObjKind::CF &&
- !pd->hasAttr<CFConsumedAttr>() &&
- NSAPIObj->isMacroDefined("CF_CONSUMED")) {
- edit::Commit commit(*Editor);
- commit.insertBefore(pd->getLocation(), "CF_CONSUMED ");
- Editor->commit(commit);
- } else if (AE.getKind() == DecRef && AE.getObjKind() == ObjKind::ObjC &&
- !pd->hasAttr<NSConsumedAttr>() &&
- NSAPIObj->isMacroDefined("NS_CONSUMED")) {
- edit::Commit commit(*Editor);
- commit.insertBefore(pd->getLocation(), "NS_CONSUMED ");
- Editor->commit(commit);
- }
- }
-}
-
-ObjCMigrateASTConsumer::CF_BRIDGING_KIND
- ObjCMigrateASTConsumer::migrateAddFunctionAnnotation(
- ASTContext &Ctx,
- const FunctionDecl *FuncDecl) {
- if (FuncDecl->hasBody())
- return CF_BRIDGING_NONE;
-
- const RetainSummary *RS =
- getSummaryManager(Ctx).getSummary(AnyCall(FuncDecl));
- bool FuncIsReturnAnnotated = (FuncDecl->hasAttr<CFReturnsRetainedAttr>() ||
- FuncDecl->hasAttr<CFReturnsNotRetainedAttr>() ||
- FuncDecl->hasAttr<NSReturnsRetainedAttr>() ||
- FuncDecl->hasAttr<NSReturnsNotRetainedAttr>() ||
- FuncDecl->hasAttr<NSReturnsAutoreleasedAttr>());
-
- // Trivial case of when function is annotated and has no argument.
- if (FuncIsReturnAnnotated && FuncDecl->getNumParams() == 0)
- return CF_BRIDGING_NONE;
-
- bool ReturnCFAudited = false;
- if (!FuncIsReturnAnnotated) {
- RetEffect Ret = RS->getRetEffect();
- if (Ret.getObjKind() == ObjKind::CF &&
- (Ret.isOwned() || Ret.notOwned()))
- ReturnCFAudited = true;
- else if (!AuditedType(FuncDecl->getReturnType()))
- return CF_BRIDGING_NONE;
- }
-
- // At this point result type is audited for potential inclusion.
- unsigned i = 0;
- bool ArgCFAudited = false;
- for (FunctionDecl::param_const_iterator pi = FuncDecl->param_begin(),
- pe = FuncDecl->param_end(); pi != pe; ++pi, ++i) {
- const ParmVarDecl *pd = *pi;
- ArgEffect AE = RS->getArg(i);
- if ((AE.getKind() == DecRef /*CFConsumed annotated*/ ||
- AE.getKind() == IncRef) && AE.getObjKind() == ObjKind::CF) {
- if (AE.getKind() == DecRef && !pd->hasAttr<CFConsumedAttr>())
- ArgCFAudited = true;
- else if (AE.getKind() == IncRef)
- ArgCFAudited = true;
- } else {
- QualType AT = pd->getType();
- if (!AuditedType(AT)) {
- AddCFAnnotations(Ctx, RS, FuncDecl, FuncIsReturnAnnotated);
- return CF_BRIDGING_NONE;
- }
- }
- }
- if (ReturnCFAudited || ArgCFAudited)
- return CF_BRIDGING_ENABLE;
-
- return CF_BRIDGING_MAY_INCLUDE;
-}
-
-void ObjCMigrateASTConsumer::migrateARCSafeAnnotation(ASTContext &Ctx,
- ObjCContainerDecl *CDecl) {
- if (!isa<ObjCInterfaceDecl>(CDecl) || CDecl->isDeprecated())
- return;
-
- // migrate methods which can have instancetype as their result type.
- for (const auto *Method : CDecl->methods())
- migrateCFAnnotation(Ctx, Method);
-}
-
-void ObjCMigrateASTConsumer::AddCFAnnotations(ASTContext &Ctx,
- const RetainSummary *RS,
- const ObjCMethodDecl *MethodDecl,
- bool ResultAnnotated) {
- // Annotate function.
- if (!ResultAnnotated) {
- RetEffect Ret = RS->getRetEffect();
- const char *AnnotationString = nullptr;
- if (Ret.getObjKind() == ObjKind::CF) {
- if (Ret.isOwned() && NSAPIObj->isMacroDefined("CF_RETURNS_RETAINED"))
- AnnotationString = " CF_RETURNS_RETAINED";
- else if (Ret.notOwned() &&
- NSAPIObj->isMacroDefined("CF_RETURNS_NOT_RETAINED"))
- AnnotationString = " CF_RETURNS_NOT_RETAINED";
- }
- else if (Ret.getObjKind() == ObjKind::ObjC) {
- ObjCMethodFamily OMF = MethodDecl->getMethodFamily();
- switch (OMF) {
- case clang::OMF_alloc:
- case clang::OMF_new:
- case clang::OMF_copy:
- case clang::OMF_init:
- case clang::OMF_mutableCopy:
- break;
-
- default:
- if (Ret.isOwned() && NSAPIObj->isMacroDefined("NS_RETURNS_RETAINED"))
- AnnotationString = " NS_RETURNS_RETAINED";
- break;
- }
- }
-
- if (AnnotationString) {
- edit::Commit commit(*Editor);
- commit.insertBefore(MethodDecl->getEndLoc(), AnnotationString);
- Editor->commit(commit);
- }
- }
- unsigned i = 0;
- for (ObjCMethodDecl::param_const_iterator pi = MethodDecl->param_begin(),
- pe = MethodDecl->param_end(); pi != pe; ++pi, ++i) {
- const ParmVarDecl *pd = *pi;
- ArgEffect AE = RS->getArg(i);
- if (AE.getKind() == DecRef
- && AE.getObjKind() == ObjKind::CF
- && !pd->hasAttr<CFConsumedAttr>() &&
- NSAPIObj->isMacroDefined("CF_CONSUMED")) {
- edit::Commit commit(*Editor);
- commit.insertBefore(pd->getLocation(), "CF_CONSUMED ");
- Editor->commit(commit);
- }
- }
-}
-
-void ObjCMigrateASTConsumer::migrateAddMethodAnnotation(
- ASTContext &Ctx,
- const ObjCMethodDecl *MethodDecl) {
- if (MethodDecl->hasBody() || MethodDecl->isImplicit())
- return;
-
- const RetainSummary *RS =
- getSummaryManager(Ctx).getSummary(AnyCall(MethodDecl));
-
- bool MethodIsReturnAnnotated =
- (MethodDecl->hasAttr<CFReturnsRetainedAttr>() ||
- MethodDecl->hasAttr<CFReturnsNotRetainedAttr>() ||
- MethodDecl->hasAttr<NSReturnsRetainedAttr>() ||
- MethodDecl->hasAttr<NSReturnsNotRetainedAttr>() ||
- MethodDecl->hasAttr<NSReturnsAutoreleasedAttr>());
-
- if (RS->getReceiverEffect().getKind() == DecRef &&
- !MethodDecl->hasAttr<NSConsumesSelfAttr>() &&
- MethodDecl->getMethodFamily() != OMF_init &&
- MethodDecl->getMethodFamily() != OMF_release &&
- NSAPIObj->isMacroDefined("NS_CONSUMES_SELF")) {
- edit::Commit commit(*Editor);
- commit.insertBefore(MethodDecl->getEndLoc(), " NS_CONSUMES_SELF");
- Editor->commit(commit);
- }
-
- // Trivial case of when function is annotated and has no argument.
- if (MethodIsReturnAnnotated &&
- (MethodDecl->param_begin() == MethodDecl->param_end()))
- return;
-
- if (!MethodIsReturnAnnotated) {
- RetEffect Ret = RS->getRetEffect();
- if ((Ret.getObjKind() == ObjKind::CF ||
- Ret.getObjKind() == ObjKind::ObjC) &&
- (Ret.isOwned() || Ret.notOwned())) {
- AddCFAnnotations(Ctx, RS, MethodDecl, false);
- return;
- } else if (!AuditedType(MethodDecl->getReturnType()))
- return;
- }
-
- // At this point result type is either annotated or audited.
- unsigned i = 0;
- for (ObjCMethodDecl::param_const_iterator pi = MethodDecl->param_begin(),
- pe = MethodDecl->param_end(); pi != pe; ++pi, ++i) {
- const ParmVarDecl *pd = *pi;
- ArgEffect AE = RS->getArg(i);
- if ((AE.getKind() == DecRef && !pd->hasAttr<CFConsumedAttr>()) ||
- AE.getKind() == IncRef || !AuditedType(pd->getType())) {
- AddCFAnnotations(Ctx, RS, MethodDecl, MethodIsReturnAnnotated);
- return;
- }
- }
-}
-
-namespace {
-class SuperInitChecker : public RecursiveASTVisitor<SuperInitChecker> {
-public:
- bool shouldVisitTemplateInstantiations() const { return false; }
- bool shouldWalkTypesOfTypeLocs() const { return false; }
-
- bool VisitObjCMessageExpr(ObjCMessageExpr *E) {
- if (E->getReceiverKind() == ObjCMessageExpr::SuperInstance) {
- if (E->getMethodFamily() == OMF_init)
- return false;
- }
- return true;
- }
-};
-} // end anonymous namespace
-
-static bool hasSuperInitCall(const ObjCMethodDecl *MD) {
- return !SuperInitChecker().TraverseStmt(MD->getBody());
-}
-
-void ObjCMigrateASTConsumer::inferDesignatedInitializers(
- ASTContext &Ctx,
- const ObjCImplementationDecl *ImplD) {
-
- const ObjCInterfaceDecl *IFace = ImplD->getClassInterface();
- if (!IFace || IFace->hasDesignatedInitializers())
- return;
- if (!NSAPIObj->isMacroDefined("NS_DESIGNATED_INITIALIZER"))
- return;
-
- for (const auto *MD : ImplD->instance_methods()) {
- if (MD->isDeprecated() ||
- MD->getMethodFamily() != OMF_init ||
- MD->isDesignatedInitializerForTheInterface())
- continue;
- const ObjCMethodDecl *IFaceM = IFace->getMethod(MD->getSelector(),
- /*isInstance=*/true);
- if (!IFaceM)
- continue;
- if (hasSuperInitCall(MD)) {
- edit::Commit commit(*Editor);
- commit.insert(IFaceM->getEndLoc(), " NS_DESIGNATED_INITIALIZER");
- Editor->commit(commit);
- }
- }
-}
-
-bool ObjCMigrateASTConsumer::InsertFoundation(ASTContext &Ctx,
- SourceLocation Loc) {
- if (FoundationIncluded)
- return true;
- if (Loc.isInvalid())
- return false;
- auto *nsEnumId = &Ctx.Idents.get("NS_ENUM");
- if (PP.getMacroDefinitionAtLoc(nsEnumId, Loc)) {
- FoundationIncluded = true;
- return true;
- }
- edit::Commit commit(*Editor);
- if (Ctx.getLangOpts().Modules)
- commit.insert(Loc, "#ifndef NS_ENUM\n at import Foundation;\n#endif\n");
- else
- commit.insert(Loc, "#ifndef NS_ENUM\n#import <Foundation/Foundation.h>\n#endif\n");
- Editor->commit(commit);
- FoundationIncluded = true;
- return true;
-}
-
-namespace {
-
-class RewritesReceiver : public edit::EditsReceiver {
- Rewriter &Rewrite;
-
-public:
- RewritesReceiver(Rewriter &Rewrite) : Rewrite(Rewrite) { }
-
- void insert(SourceLocation loc, StringRef text) override {
- Rewrite.InsertText(loc, text);
- }
- void replace(CharSourceRange range, StringRef text) override {
- Rewrite.ReplaceText(range.getBegin(), Rewrite.getRangeSize(range), text);
- }
-};
-
-class JSONEditWriter : public edit::EditsReceiver {
- SourceManager &SourceMgr;
- llvm::raw_ostream &OS;
-
-public:
- JSONEditWriter(SourceManager &SM, llvm::raw_ostream &OS)
- : SourceMgr(SM), OS(OS) {
- OS << "[\n";
- }
- ~JSONEditWriter() override { OS << "]\n"; }
-
-private:
- struct EntryWriter {
- SourceManager &SourceMgr;
- llvm::raw_ostream &OS;
-
- EntryWriter(SourceManager &SM, llvm::raw_ostream &OS)
- : SourceMgr(SM), OS(OS) {
- OS << " {\n";
- }
- ~EntryWriter() {
- OS << " },\n";
- }
-
- void writeLoc(SourceLocation Loc) {
- FileID FID;
- unsigned Offset;
- std::tie(FID, Offset) = SourceMgr.getDecomposedLoc(Loc);
- assert(FID.isValid());
- SmallString<200> Path =
- StringRef(SourceMgr.getFileEntryRefForID(FID)->getName());
- llvm::sys::fs::make_absolute(Path);
- OS << " \"file\": \"";
- OS.write_escaped(Path.str()) << "\",\n";
- OS << " \"offset\": " << Offset << ",\n";
- }
-
- void writeRemove(CharSourceRange Range) {
- assert(Range.isCharRange());
- std::pair<FileID, unsigned> Begin =
- SourceMgr.getDecomposedLoc(Range.getBegin());
- std::pair<FileID, unsigned> End =
- SourceMgr.getDecomposedLoc(Range.getEnd());
- assert(Begin.first == End.first);
- assert(Begin.second <= End.second);
- unsigned Length = End.second - Begin.second;
-
- OS << " \"remove\": " << Length << ",\n";
- }
-
- void writeText(StringRef Text) {
- OS << " \"text\": \"";
- OS.write_escaped(Text) << "\",\n";
- }
- };
-
- void insert(SourceLocation Loc, StringRef Text) override {
- EntryWriter Writer(SourceMgr, OS);
- Writer.writeLoc(Loc);
- Writer.writeText(Text);
- }
-
- void replace(CharSourceRange Range, StringRef Text) override {
- EntryWriter Writer(SourceMgr, OS);
- Writer.writeLoc(Range.getBegin());
- Writer.writeRemove(Range);
- Writer.writeText(Text);
- }
-
- void remove(CharSourceRange Range) override {
- EntryWriter Writer(SourceMgr, OS);
- Writer.writeLoc(Range.getBegin());
- Writer.writeRemove(Range);
- }
-};
-
-} // end anonymous namespace
-
-void ObjCMigrateASTConsumer::HandleTranslationUnit(ASTContext &Ctx) {
-
- TranslationUnitDecl *TU = Ctx.getTranslationUnitDecl();
- if (ASTMigrateActions & FrontendOptions::ObjCMT_MigrateDecls) {
- for (DeclContext::decl_iterator D = TU->decls_begin(), DEnd = TU->decls_end();
- D != DEnd; ++D) {
- FileID FID = PP.getSourceManager().getFileID((*D)->getLocation());
- if (FID.isValid())
- if (FileId.isValid() && FileId != FID) {
- if (ASTMigrateActions & FrontendOptions::ObjCMT_Annotation)
- AnnotateImplicitBridging(Ctx);
- }
-
- if (ObjCInterfaceDecl *CDecl = dyn_cast<ObjCInterfaceDecl>(*D))
- if (canModify(CDecl))
- migrateObjCContainerDecl(Ctx, CDecl);
- if (ObjCCategoryDecl *CatDecl = dyn_cast<ObjCCategoryDecl>(*D)) {
- if (canModify(CatDecl))
- migrateObjCContainerDecl(Ctx, CatDecl);
- }
- else if (ObjCProtocolDecl *PDecl = dyn_cast<ObjCProtocolDecl>(*D)) {
- ObjCProtocolDecls.insert(PDecl->getCanonicalDecl());
- if (canModify(PDecl))
- migrateObjCContainerDecl(Ctx, PDecl);
- }
- else if (const ObjCImplementationDecl *ImpDecl =
- dyn_cast<ObjCImplementationDecl>(*D)) {
- if ((ASTMigrateActions & FrontendOptions::ObjCMT_ProtocolConformance) &&
- canModify(ImpDecl))
- migrateProtocolConformance(Ctx, ImpDecl);
- }
- else if (const EnumDecl *ED = dyn_cast<EnumDecl>(*D)) {
- if (!(ASTMigrateActions & FrontendOptions::ObjCMT_NsMacros))
- continue;
- if (!canModify(ED))
- continue;
- DeclContext::decl_iterator N = D;
- if (++N != DEnd) {
- const TypedefDecl *TD = dyn_cast<TypedefDecl>(*N);
- if (migrateNSEnumDecl(Ctx, ED, TD) && TD)
- D++;
- }
- else
- migrateNSEnumDecl(Ctx, ED, /*TypedefDecl */nullptr);
- }
- else if (const TypedefDecl *TD = dyn_cast<TypedefDecl>(*D)) {
- if (!(ASTMigrateActions & FrontendOptions::ObjCMT_NsMacros))
- continue;
- if (!canModify(TD))
- continue;
- DeclContext::decl_iterator N = D;
- if (++N == DEnd)
- continue;
- if (const EnumDecl *ED = dyn_cast<EnumDecl>(*N)) {
- if (canModify(ED)) {
- if (++N != DEnd)
- if (const TypedefDecl *TDF = dyn_cast<TypedefDecl>(*N)) {
- // prefer typedef-follows-enum to enum-follows-typedef pattern.
- if (migrateNSEnumDecl(Ctx, ED, TDF)) {
- ++D; ++D;
- CacheObjCNSIntegerTypedefed(TD);
- continue;
- }
- }
- if (migrateNSEnumDecl(Ctx, ED, TD)) {
- ++D;
- continue;
- }
- }
- }
- CacheObjCNSIntegerTypedefed(TD);
- }
- else if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(*D)) {
- if ((ASTMigrateActions & FrontendOptions::ObjCMT_Annotation) &&
- canModify(FD))
- migrateCFAnnotation(Ctx, FD);
- }
-
- if (ObjCContainerDecl *CDecl = dyn_cast<ObjCContainerDecl>(*D)) {
- bool CanModify = canModify(CDecl);
- // migrate methods which can have instancetype as their result type.
- if ((ASTMigrateActions & FrontendOptions::ObjCMT_Instancetype) &&
- CanModify)
- migrateAllMethodInstaceType(Ctx, CDecl);
- // annotate methods with CF annotations.
- if ((ASTMigrateActions & FrontendOptions::ObjCMT_Annotation) &&
- CanModify)
- migrateARCSafeAnnotation(Ctx, CDecl);
- }
-
- if (const ObjCImplementationDecl *
- ImplD = dyn_cast<ObjCImplementationDecl>(*D)) {
- if ((ASTMigrateActions & FrontendOptions::ObjCMT_DesignatedInitializer) &&
- canModify(ImplD))
- inferDesignatedInitializers(Ctx, ImplD);
- }
- }
- if (ASTMigrateActions & FrontendOptions::ObjCMT_Annotation)
- AnnotateImplicitBridging(Ctx);
- }
-
- if (IsOutputFile) {
- std::error_code EC;
- llvm::raw_fd_ostream OS(MigrateDir, EC, llvm::sys::fs::OF_None);
- if (EC) {
- DiagnosticsEngine &Diags = Ctx.getDiagnostics();
- Diags.Report(Diags.getCustomDiagID(DiagnosticsEngine::Error, "%0"))
- << EC.message();
- return;
- }
-
- JSONEditWriter Writer(Ctx.getSourceManager(), OS);
- Editor->applyRewrites(Writer);
- return;
- }
-
- Rewriter rewriter(Ctx.getSourceManager(), Ctx.getLangOpts());
- RewritesReceiver Rec(rewriter);
- Editor->applyRewrites(Rec);
-
- for (Rewriter::buffer_iterator
- I = rewriter.buffer_begin(), E = rewriter.buffer_end(); I != E; ++I) {
- FileID FID = I->first;
- RewriteBuffer &buf = I->second;
- OptionalFileEntryRef file =
- Ctx.getSourceManager().getFileEntryRefForID(FID);
- assert(file);
- SmallString<512> newText;
- llvm::raw_svector_ostream vecOS(newText);
- buf.write(vecOS);
- std::unique_ptr<llvm::MemoryBuffer> memBuf(
- llvm::MemoryBuffer::getMemBufferCopy(newText.str(), file->getName()));
- SmallString<64> filePath(file->getName());
- FileMgr.FixupRelativePath(filePath);
- Remapper.remap(filePath.str(), std::move(memBuf));
- }
-
- if (IsOutputFile) {
- Remapper.flushToFile(MigrateDir, Ctx.getDiagnostics());
- } else {
- Remapper.flushToDisk(MigrateDir, Ctx.getDiagnostics());
- }
-}
-
-bool MigrateSourceAction::BeginInvocation(CompilerInstance &CI) {
- CI.getDiagnostics().setIgnoreAllWarnings(true);
- return true;
-}
-
-static std::vector<std::string> getAllowListFilenames(StringRef DirPath) {
- using namespace llvm::sys::fs;
- using namespace llvm::sys::path;
-
- std::vector<std::string> Filenames;
- if (DirPath.empty() || !is_directory(DirPath))
- return Filenames;
-
- std::error_code EC;
- directory_iterator DI = directory_iterator(DirPath, EC);
- directory_iterator DE;
- for (; !EC && DI != DE; DI = DI.increment(EC)) {
- if (is_regular_file(DI->path()))
- Filenames.push_back(std::string(filename(DI->path())));
- }
-
- return Filenames;
-}
-
-std::unique_ptr<ASTConsumer>
-MigrateSourceAction::CreateASTConsumer(CompilerInstance &CI, StringRef InFile) {
- PPConditionalDirectiveRecord *
- PPRec = new PPConditionalDirectiveRecord(CI.getSourceManager());
- unsigned ObjCMTAction = CI.getFrontendOpts().ObjCMTAction;
- unsigned ObjCMTOpts = ObjCMTAction;
- // These are companion flags, they do not enable transformations.
- ObjCMTOpts &= ~(FrontendOptions::ObjCMT_AtomicProperty |
- FrontendOptions::ObjCMT_NsAtomicIOSOnlyProperty);
- if (ObjCMTOpts == FrontendOptions::ObjCMT_None) {
- // If no specific option was given, enable literals+subscripting transforms
- // by default.
- ObjCMTAction |=
- FrontendOptions::ObjCMT_Literals | FrontendOptions::ObjCMT_Subscripting;
- }
- CI.getPreprocessor().addPPCallbacks(std::unique_ptr<PPCallbacks>(PPRec));
- std::vector<std::string> AllowList =
- getAllowListFilenames(CI.getFrontendOpts().ObjCMTAllowListPath);
- return std::make_unique<ObjCMigrateASTConsumer>(
- CI.getFrontendOpts().OutputFile, ObjCMTAction, Remapper,
- CI.getFileManager(), PPRec, CI.getPreprocessor(),
- /*isOutputFile=*/true, AllowList);
-}
-
-namespace {
-struct EditEntry {
- OptionalFileEntryRef File;
- unsigned Offset = 0;
- unsigned RemoveLen = 0;
- std::string Text;
-};
-} // end anonymous namespace
-
-namespace llvm {
-template<> struct DenseMapInfo<EditEntry> {
- static inline EditEntry getEmptyKey() {
- EditEntry Entry;
- Entry.Offset = unsigned(-1);
- return Entry;
- }
- static inline EditEntry getTombstoneKey() {
- EditEntry Entry;
- Entry.Offset = unsigned(-2);
- return Entry;
- }
- static unsigned getHashValue(const EditEntry& Val) {
- return (unsigned)llvm::hash_combine(Val.File, Val.Offset, Val.RemoveLen,
- Val.Text);
- }
- static bool isEqual(const EditEntry &LHS, const EditEntry &RHS) {
- return LHS.File == RHS.File &&
- LHS.Offset == RHS.Offset &&
- LHS.RemoveLen == RHS.RemoveLen &&
- LHS.Text == RHS.Text;
- }
-};
-} // end namespace llvm
-
-namespace {
-class RemapFileParser {
- FileManager &FileMgr;
-
-public:
- RemapFileParser(FileManager &FileMgr) : FileMgr(FileMgr) { }
-
- bool parse(StringRef File, SmallVectorImpl<EditEntry> &Entries) {
- using namespace llvm::yaml;
-
- llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> FileBufOrErr =
- llvm::MemoryBuffer::getFile(File);
- if (!FileBufOrErr)
- return true;
-
- llvm::SourceMgr SM;
- Stream YAMLStream(FileBufOrErr.get()->getMemBufferRef(), SM);
- document_iterator I = YAMLStream.begin();
- if (I == YAMLStream.end())
- return true;
- Node *Root = I->getRoot();
- if (!Root)
- return true;
-
- SequenceNode *SeqNode = dyn_cast<SequenceNode>(Root);
- if (!SeqNode)
- return true;
-
- for (SequenceNode::iterator
- AI = SeqNode->begin(), AE = SeqNode->end(); AI != AE; ++AI) {
- MappingNode *MapNode = dyn_cast<MappingNode>(&*AI);
- if (!MapNode)
- continue;
- parseEdit(MapNode, Entries);
- }
-
- return false;
- }
-
-private:
- void parseEdit(llvm::yaml::MappingNode *Node,
- SmallVectorImpl<EditEntry> &Entries) {
- using namespace llvm::yaml;
- EditEntry Entry;
- bool Ignore = false;
-
- for (MappingNode::iterator
- KVI = Node->begin(), KVE = Node->end(); KVI != KVE; ++KVI) {
- ScalarNode *KeyString = dyn_cast<ScalarNode>((*KVI).getKey());
- if (!KeyString)
- continue;
- SmallString<10> KeyStorage;
- StringRef Key = KeyString->getValue(KeyStorage);
-
- ScalarNode *ValueString = dyn_cast<ScalarNode>((*KVI).getValue());
- if (!ValueString)
- continue;
- SmallString<64> ValueStorage;
- StringRef Val = ValueString->getValue(ValueStorage);
-
- if (Key == "file") {
- if (auto File = FileMgr.getOptionalFileRef(Val))
- Entry.File = File;
- else
- Ignore = true;
- } else if (Key == "offset") {
- if (Val.getAsInteger(10, Entry.Offset))
- Ignore = true;
- } else if (Key == "remove") {
- if (Val.getAsInteger(10, Entry.RemoveLen))
- Ignore = true;
- } else if (Key == "text") {
- Entry.Text = std::string(Val);
- }
- }
-
- if (!Ignore)
- Entries.push_back(Entry);
- }
-};
-} // end anonymous namespace
-
-static bool reportDiag(const Twine &Err, DiagnosticsEngine &Diag) {
- Diag.Report(Diag.getCustomDiagID(DiagnosticsEngine::Error, "%0"))
- << Err.str();
- return true;
-}
-
-static std::string applyEditsToTemp(FileEntryRef FE,
- ArrayRef<EditEntry> Edits,
- FileManager &FileMgr,
- DiagnosticsEngine &Diag) {
- using namespace llvm::sys;
-
- SourceManager SM(Diag, FileMgr);
- FileID FID = SM.createFileID(FE, SourceLocation(), SrcMgr::C_User);
- LangOptions LangOpts;
- edit::EditedSource Editor(SM, LangOpts);
- for (ArrayRef<EditEntry>::iterator
- I = Edits.begin(), E = Edits.end(); I != E; ++I) {
- const EditEntry &Entry = *I;
- assert(Entry.File == FE);
- SourceLocation Loc =
- SM.getLocForStartOfFile(FID).getLocWithOffset(Entry.Offset);
- CharSourceRange Range;
- if (Entry.RemoveLen != 0) {
- Range = CharSourceRange::getCharRange(Loc,
- Loc.getLocWithOffset(Entry.RemoveLen));
- }
-
- edit::Commit commit(Editor);
- if (Range.isInvalid()) {
- commit.insert(Loc, Entry.Text);
- } else if (Entry.Text.empty()) {
- commit.remove(Range);
- } else {
- commit.replace(Range, Entry.Text);
- }
- Editor.commit(commit);
- }
-
- Rewriter rewriter(SM, LangOpts);
- RewritesReceiver Rec(rewriter);
- Editor.applyRewrites(Rec, /*adjustRemovals=*/false);
-
- const RewriteBuffer *Buf = rewriter.getRewriteBufferFor(FID);
- SmallString<512> NewText;
- llvm::raw_svector_ostream OS(NewText);
- Buf->write(OS);
-
- SmallString<64> TempPath;
- int FD;
- if (fs::createTemporaryFile(path::filename(FE.getName()),
- path::extension(FE.getName()).drop_front(), FD,
- TempPath)) {
- reportDiag("Could not create file: " + TempPath.str(), Diag);
- return std::string();
- }
-
- llvm::raw_fd_ostream TmpOut(FD, /*shouldClose=*/true);
- TmpOut.write(NewText.data(), NewText.size());
- TmpOut.close();
-
- return std::string(TempPath);
-}
-
-bool arcmt::getFileRemappingsFromFileList(
- std::vector<std::pair<std::string,std::string> > &remap,
- ArrayRef<StringRef> remapFiles,
- DiagnosticConsumer *DiagClient) {
- bool hasErrorOccurred = false;
-
- FileSystemOptions FSOpts;
- FileManager FileMgr(FSOpts);
- RemapFileParser Parser(FileMgr);
-
- IntrusiveRefCntPtr<DiagnosticIDs> DiagID(new DiagnosticIDs());
- IntrusiveRefCntPtr<DiagnosticsEngine> Diags(
- new DiagnosticsEngine(DiagID, new DiagnosticOptions,
- DiagClient, /*ShouldOwnClient=*/false));
-
- typedef llvm::DenseMap<FileEntryRef, std::vector<EditEntry> >
- FileEditEntriesTy;
- FileEditEntriesTy FileEditEntries;
-
- llvm::DenseSet<EditEntry> EntriesSet;
-
- for (ArrayRef<StringRef>::iterator
- I = remapFiles.begin(), E = remapFiles.end(); I != E; ++I) {
- SmallVector<EditEntry, 16> Entries;
- if (Parser.parse(*I, Entries))
- continue;
-
- for (SmallVectorImpl<EditEntry>::iterator
- EI = Entries.begin(), EE = Entries.end(); EI != EE; ++EI) {
- EditEntry &Entry = *EI;
- if (!Entry.File)
- continue;
- std::pair<llvm::DenseSet<EditEntry>::iterator, bool>
- Insert = EntriesSet.insert(Entry);
- if (!Insert.second)
- continue;
-
- FileEditEntries[*Entry.File].push_back(Entry);
- }
- }
-
- for (FileEditEntriesTy::iterator
- I = FileEditEntries.begin(), E = FileEditEntries.end(); I != E; ++I) {
- std::string TempFile = applyEditsToTemp(I->first, I->second,
- FileMgr, *Diags);
- if (TempFile.empty()) {
- hasErrorOccurred = true;
- continue;
- }
-
- remap.emplace_back(std::string(I->first.getName()), TempFile);
- }
-
- return hasErrorOccurred;
-}
diff --git a/clang/lib/ARCMigrate/PlistReporter.cpp b/clang/lib/ARCMigrate/PlistReporter.cpp
deleted file mode 100644
index f78ca5e1c9bdd9..00000000000000
--- a/clang/lib/ARCMigrate/PlistReporter.cpp
+++ /dev/null
@@ -1,124 +0,0 @@
-//===--- PlistReporter.cpp - ARC Migrate Tool Plist Reporter ----*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#include "Internals.h"
-#include "clang/Basic/FileManager.h"
-#include "clang/Basic/PlistSupport.h"
-#include "clang/Basic/SourceManager.h"
-#include "clang/Lex/Lexer.h"
-using namespace clang;
-using namespace arcmt;
-using namespace markup;
-
-static StringRef getLevelName(DiagnosticsEngine::Level Level) {
- switch (Level) {
- case DiagnosticsEngine::Ignored:
- llvm_unreachable("ignored");
- case DiagnosticsEngine::Note:
- return "note";
- case DiagnosticsEngine::Remark:
- case DiagnosticsEngine::Warning:
- return "warning";
- case DiagnosticsEngine::Fatal:
- case DiagnosticsEngine::Error:
- return "error";
- }
- llvm_unreachable("Invalid DiagnosticsEngine level!");
-}
-
-void arcmt::writeARCDiagsToPlist(const std::string &outPath,
- ArrayRef<StoredDiagnostic> diags,
- SourceManager &SM,
- const LangOptions &LangOpts) {
- DiagnosticIDs DiagIDs;
-
- // Build up a set of FIDs that we use by scanning the locations and
- // ranges of the diagnostics.
- FIDMap FM;
- SmallVector<FileID, 10> Fids;
-
- for (ArrayRef<StoredDiagnostic>::iterator
- I = diags.begin(), E = diags.end(); I != E; ++I) {
- const StoredDiagnostic &D = *I;
-
- AddFID(FM, Fids, SM, D.getLocation());
-
- for (StoredDiagnostic::range_iterator
- RI = D.range_begin(), RE = D.range_end(); RI != RE; ++RI) {
- AddFID(FM, Fids, SM, RI->getBegin());
- AddFID(FM, Fids, SM, RI->getEnd());
- }
- }
-
- std::error_code EC;
- llvm::raw_fd_ostream o(outPath, EC, llvm::sys::fs::OF_TextWithCRLF);
- if (EC) {
- llvm::errs() << "error: could not create file: " << outPath << '\n';
- return;
- }
-
- EmitPlistHeader(o);
-
- // Write the root object: a <dict> containing...
- // - "files", an <array> mapping from FIDs to file names
- // - "diagnostics", an <array> containing the diagnostics
- o << "<dict>\n"
- " <key>files</key>\n"
- " <array>\n";
-
- for (FileID FID : Fids)
- EmitString(o << " ", SM.getFileEntryRefForID(FID)->getName()) << '\n';
-
- o << " </array>\n"
- " <key>diagnostics</key>\n"
- " <array>\n";
-
- for (ArrayRef<StoredDiagnostic>::iterator
- DI = diags.begin(), DE = diags.end(); DI != DE; ++DI) {
-
- const StoredDiagnostic &D = *DI;
-
- if (D.getLevel() == DiagnosticsEngine::Ignored)
- continue;
-
- o << " <dict>\n";
-
- // Output the diagnostic.
- o << " <key>description</key>";
- EmitString(o, D.getMessage()) << '\n';
- o << " <key>category</key>";
- EmitString(o, DiagIDs.getCategoryNameFromID(
- DiagIDs.getCategoryNumberForDiag(D.getID()))) << '\n';
- o << " <key>type</key>";
- EmitString(o, getLevelName(D.getLevel())) << '\n';
-
- // Output the location of the bug.
- o << " <key>location</key>\n";
- EmitLocation(o, SM, D.getLocation(), FM, 2);
-
- // Output the ranges (if any).
- if (!D.getRanges().empty()) {
- o << " <key>ranges</key>\n";
- o << " <array>\n";
- for (auto &R : D.getRanges()) {
- CharSourceRange ExpansionRange = SM.getExpansionRange(R);
- EmitRange(o, SM, Lexer::getAsCharRange(ExpansionRange, SM, LangOpts),
- FM, 4);
- }
- o << " </array>\n";
- }
-
- // Close up the entry.
- o << " </dict>\n";
- }
-
- o << " </array>\n";
-
- // Finish.
- o << "</dict>\n</plist>\n";
-}
diff --git a/clang/lib/ARCMigrate/TransAPIUses.cpp b/clang/lib/ARCMigrate/TransAPIUses.cpp
deleted file mode 100644
index 8f5d4f4bde06ca..00000000000000
--- a/clang/lib/ARCMigrate/TransAPIUses.cpp
+++ /dev/null
@@ -1,107 +0,0 @@
-//===--- TransAPIUses.cpp - Transformations to ARC mode -------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-//
-// checkAPIUses:
-//
-// Emits error/fix with some API uses that are obsolete or not safe in ARC mode:
-//
-// - NSInvocation's [get/set]ReturnValue and [get/set]Argument are only safe
-// with __unsafe_unretained objects.
-// - Calling -zone gets replaced with 'nil'.
-//
-//===----------------------------------------------------------------------===//
-
-#include "Transforms.h"
-#include "Internals.h"
-#include "clang/AST/ASTContext.h"
-#include "clang/Sema/SemaDiagnostic.h"
-
-using namespace clang;
-using namespace arcmt;
-using namespace trans;
-
-namespace {
-
-class APIChecker : public RecursiveASTVisitor<APIChecker> {
- MigrationPass &Pass;
-
- Selector getReturnValueSel, setReturnValueSel;
- Selector getArgumentSel, setArgumentSel;
-
- Selector zoneSel;
-public:
- APIChecker(MigrationPass &pass) : Pass(pass) {
- SelectorTable &sels = Pass.Ctx.Selectors;
- IdentifierTable &ids = Pass.Ctx.Idents;
- getReturnValueSel = sels.getUnarySelector(&ids.get("getReturnValue"));
- setReturnValueSel = sels.getUnarySelector(&ids.get("setReturnValue"));
-
- const IdentifierInfo *selIds[2];
- selIds[0] = &ids.get("getArgument");
- selIds[1] = &ids.get("atIndex");
- getArgumentSel = sels.getSelector(2, selIds);
- selIds[0] = &ids.get("setArgument");
- setArgumentSel = sels.getSelector(2, selIds);
-
- zoneSel = sels.getNullarySelector(&ids.get("zone"));
- }
-
- bool VisitObjCMessageExpr(ObjCMessageExpr *E) {
- // NSInvocation.
- if (E->isInstanceMessage() &&
- E->getReceiverInterface() &&
- E->getReceiverInterface()->getName() == "NSInvocation") {
- StringRef selName;
- if (E->getSelector() == getReturnValueSel)
- selName = "getReturnValue";
- else if (E->getSelector() == setReturnValueSel)
- selName = "setReturnValue";
- else if (E->getSelector() == getArgumentSel)
- selName = "getArgument";
- else if (E->getSelector() == setArgumentSel)
- selName = "setArgument";
- else
- return true;
-
- Expr *parm = E->getArg(0)->IgnoreParenCasts();
- QualType pointee = parm->getType()->getPointeeType();
- if (pointee.isNull())
- return true;
-
- if (pointee.getObjCLifetime() > Qualifiers::OCL_ExplicitNone)
- Pass.TA.report(parm->getBeginLoc(),
- diag::err_arcmt_nsinvocation_ownership,
- parm->getSourceRange())
- << selName;
-
- return true;
- }
-
- // -zone.
- if (E->isInstanceMessage() &&
- E->getInstanceReceiver() &&
- E->getSelector() == zoneSel &&
- Pass.TA.hasDiagnostic(diag::err_unavailable,
- diag::err_unavailable_message,
- E->getSelectorLoc(0))) {
- // Calling -zone is meaningless in ARC, change it to nil.
- Transaction Trans(Pass.TA);
- Pass.TA.clearDiagnostic(diag::err_unavailable,
- diag::err_unavailable_message,
- E->getSelectorLoc(0));
- Pass.TA.replace(E->getSourceRange(), getNilString(Pass));
- }
- return true;
- }
-};
-
-} // anonymous namespace
-
-void trans::checkAPIUses(MigrationPass &pass) {
- APIChecker(pass).TraverseDecl(pass.Ctx.getTranslationUnitDecl());
-}
diff --git a/clang/lib/ARCMigrate/TransARCAssign.cpp b/clang/lib/ARCMigrate/TransARCAssign.cpp
deleted file mode 100644
index d1d5b9e014b17a..00000000000000
--- a/clang/lib/ARCMigrate/TransARCAssign.cpp
+++ /dev/null
@@ -1,77 +0,0 @@
-//===--- TransARCAssign.cpp - Transformations to ARC mode -----------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-//
-// makeAssignARCSafe:
-//
-// Add '__strong' where appropriate.
-//
-// for (id x in collection) {
-// x = 0;
-// }
-// ---->
-// for (__strong id x in collection) {
-// x = 0;
-// }
-//
-//===----------------------------------------------------------------------===//
-
-#include "Transforms.h"
-#include "Internals.h"
-#include "clang/AST/ASTContext.h"
-#include "clang/Sema/SemaDiagnostic.h"
-
-using namespace clang;
-using namespace arcmt;
-using namespace trans;
-
-namespace {
-
-class ARCAssignChecker : public RecursiveASTVisitor<ARCAssignChecker> {
- MigrationPass &Pass;
- llvm::DenseSet<VarDecl *> ModifiedVars;
-
-public:
- ARCAssignChecker(MigrationPass &pass) : Pass(pass) { }
-
- bool VisitBinaryOperator(BinaryOperator *Exp) {
- if (Exp->getType()->isDependentType())
- return true;
-
- Expr *E = Exp->getLHS();
- SourceLocation OrigLoc = E->getExprLoc();
- SourceLocation Loc = OrigLoc;
- DeclRefExpr *declRef = dyn_cast<DeclRefExpr>(E->IgnoreParenCasts());
- if (declRef && isa<VarDecl>(declRef->getDecl())) {
- ASTContext &Ctx = Pass.Ctx;
- Expr::isModifiableLvalueResult IsLV = E->isModifiableLvalue(Ctx, &Loc);
- if (IsLV != Expr::MLV_ConstQualified)
- return true;
- VarDecl *var = cast<VarDecl>(declRef->getDecl());
- if (var->isARCPseudoStrong()) {
- Transaction Trans(Pass.TA);
- if (Pass.TA.clearDiagnostic(diag::err_typecheck_arr_assign_enumeration,
- Exp->getOperatorLoc())) {
- if (!ModifiedVars.count(var)) {
- TypeLoc TLoc = var->getTypeSourceInfo()->getTypeLoc();
- Pass.TA.insert(TLoc.getBeginLoc(), "__strong ");
- ModifiedVars.insert(var);
- }
- }
- }
- }
-
- return true;
- }
-};
-
-} // anonymous namespace
-
-void trans::makeAssignARCSafe(MigrationPass &pass) {
- ARCAssignChecker assignCheck(pass);
- assignCheck.TraverseDecl(pass.Ctx.getTranslationUnitDecl());
-}
diff --git a/clang/lib/ARCMigrate/TransAutoreleasePool.cpp b/clang/lib/ARCMigrate/TransAutoreleasePool.cpp
deleted file mode 100644
index 6d501228e712b2..00000000000000
--- a/clang/lib/ARCMigrate/TransAutoreleasePool.cpp
+++ /dev/null
@@ -1,435 +0,0 @@
-//===--- TransAutoreleasePool.cpp - Transformations to ARC mode -----------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-//
-// rewriteAutoreleasePool:
-//
-// Calls to NSAutoreleasePools will be rewritten as an @autorelease scope.
-//
-// NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-// ...
-// [pool release];
-// ---->
-// @autorelease {
-// ...
-// }
-//
-// An NSAutoreleasePool will not be touched if:
-// - There is not a corresponding -release/-drain in the same scope
-// - Not all references of the NSAutoreleasePool variable can be removed
-// - There is a variable that is declared inside the intended @autorelease scope
-// which is also used outside it.
-//
-//===----------------------------------------------------------------------===//
-
-#include "Transforms.h"
-#include "Internals.h"
-#include "clang/AST/ASTContext.h"
-#include "clang/Basic/SourceManager.h"
-#include "clang/Sema/SemaDiagnostic.h"
-#include <map>
-
-using namespace clang;
-using namespace arcmt;
-using namespace trans;
-
-namespace {
-
-class ReleaseCollector : public RecursiveASTVisitor<ReleaseCollector> {
- Decl *Dcl;
- SmallVectorImpl<ObjCMessageExpr *> &Releases;
-
-public:
- ReleaseCollector(Decl *D, SmallVectorImpl<ObjCMessageExpr *> &releases)
- : Dcl(D), Releases(releases) { }
-
- bool VisitObjCMessageExpr(ObjCMessageExpr *E) {
- if (!E->isInstanceMessage())
- return true;
- if (E->getMethodFamily() != OMF_release)
- return true;
- Expr *instance = E->getInstanceReceiver()->IgnoreParenCasts();
- if (DeclRefExpr *DE = dyn_cast<DeclRefExpr>(instance)) {
- if (DE->getDecl() == Dcl)
- Releases.push_back(E);
- }
- return true;
- }
-};
-
-}
-
-namespace {
-
-class AutoreleasePoolRewriter
- : public RecursiveASTVisitor<AutoreleasePoolRewriter> {
-public:
- AutoreleasePoolRewriter(MigrationPass &pass)
- : Body(nullptr), Pass(pass) {
- PoolII = &pass.Ctx.Idents.get("NSAutoreleasePool");
- DrainSel = pass.Ctx.Selectors.getNullarySelector(
- &pass.Ctx.Idents.get("drain"));
- }
-
- void transformBody(Stmt *body, Decl *ParentD) {
- Body = body;
- TraverseStmt(body);
- }
-
- ~AutoreleasePoolRewriter() {
- SmallVector<VarDecl *, 8> VarsToHandle;
-
- for (std::map<VarDecl *, PoolVarInfo>::iterator
- I = PoolVars.begin(), E = PoolVars.end(); I != E; ++I) {
- VarDecl *var = I->first;
- PoolVarInfo &info = I->second;
-
- // Check that we can handle/rewrite all references of the pool.
-
- clearRefsIn(info.Dcl, info.Refs);
- for (SmallVectorImpl<PoolScope>::iterator
- scpI = info.Scopes.begin(),
- scpE = info.Scopes.end(); scpI != scpE; ++scpI) {
- PoolScope &scope = *scpI;
- clearRefsIn(*scope.Begin, info.Refs);
- clearRefsIn(*scope.End, info.Refs);
- clearRefsIn(scope.Releases.begin(), scope.Releases.end(), info.Refs);
- }
-
- // Even if one reference is not handled we will not do anything about that
- // pool variable.
- if (info.Refs.empty())
- VarsToHandle.push_back(var);
- }
-
- for (unsigned i = 0, e = VarsToHandle.size(); i != e; ++i) {
- PoolVarInfo &info = PoolVars[VarsToHandle[i]];
-
- Transaction Trans(Pass.TA);
-
- clearUnavailableDiags(info.Dcl);
- Pass.TA.removeStmt(info.Dcl);
-
- // Add "@autoreleasepool { }"
- for (SmallVectorImpl<PoolScope>::iterator
- scpI = info.Scopes.begin(),
- scpE = info.Scopes.end(); scpI != scpE; ++scpI) {
- PoolScope &scope = *scpI;
- clearUnavailableDiags(*scope.Begin);
- clearUnavailableDiags(*scope.End);
- if (scope.IsFollowedBySimpleReturnStmt) {
- // Include the return in the scope.
- Pass.TA.replaceStmt(*scope.Begin, "@autoreleasepool {");
- Pass.TA.removeStmt(*scope.End);
- Stmt::child_iterator retI = scope.End;
- ++retI;
- SourceLocation afterSemi =
- findLocationAfterSemi((*retI)->getEndLoc(), Pass.Ctx);
- assert(afterSemi.isValid() &&
- "Didn't we check before setting IsFollowedBySimpleReturnStmt "
- "to true?");
- Pass.TA.insertAfterToken(afterSemi, "\n}");
- Pass.TA.increaseIndentation(
- SourceRange(scope.getIndentedRange().getBegin(),
- (*retI)->getEndLoc()),
- scope.CompoundParent->getBeginLoc());
- } else {
- Pass.TA.replaceStmt(*scope.Begin, "@autoreleasepool {");
- Pass.TA.replaceStmt(*scope.End, "}");
- Pass.TA.increaseIndentation(scope.getIndentedRange(),
- scope.CompoundParent->getBeginLoc());
- }
- }
-
- // Remove rest of pool var references.
- for (SmallVectorImpl<PoolScope>::iterator
- scpI = info.Scopes.begin(),
- scpE = info.Scopes.end(); scpI != scpE; ++scpI) {
- PoolScope &scope = *scpI;
- for (SmallVectorImpl<ObjCMessageExpr *>::iterator
- relI = scope.Releases.begin(),
- relE = scope.Releases.end(); relI != relE; ++relI) {
- clearUnavailableDiags(*relI);
- Pass.TA.removeStmt(*relI);
- }
- }
- }
- }
-
- bool VisitCompoundStmt(CompoundStmt *S) {
- SmallVector<PoolScope, 4> Scopes;
-
- for (Stmt::child_iterator
- I = S->body_begin(), E = S->body_end(); I != E; ++I) {
- Stmt *child = getEssential(*I);
- if (DeclStmt *DclS = dyn_cast<DeclStmt>(child)) {
- if (DclS->isSingleDecl()) {
- if (VarDecl *VD = dyn_cast<VarDecl>(DclS->getSingleDecl())) {
- if (isNSAutoreleasePool(VD->getType())) {
- PoolVarInfo &info = PoolVars[VD];
- info.Dcl = DclS;
- collectRefs(VD, S, info.Refs);
- // Does this statement follow the pattern:
- // NSAutoreleasePool * pool = [NSAutoreleasePool new];
- if (isPoolCreation(VD->getInit())) {
- Scopes.push_back(PoolScope());
- Scopes.back().PoolVar = VD;
- Scopes.back().CompoundParent = S;
- Scopes.back().Begin = I;
- }
- }
- }
- }
- } else if (BinaryOperator *bop = dyn_cast<BinaryOperator>(child)) {
- if (DeclRefExpr *dref = dyn_cast<DeclRefExpr>(bop->getLHS())) {
- if (VarDecl *VD = dyn_cast<VarDecl>(dref->getDecl())) {
- // Does this statement follow the pattern:
- // pool = [NSAutoreleasePool new];
- if (isNSAutoreleasePool(VD->getType()) &&
- isPoolCreation(bop->getRHS())) {
- Scopes.push_back(PoolScope());
- Scopes.back().PoolVar = VD;
- Scopes.back().CompoundParent = S;
- Scopes.back().Begin = I;
- }
- }
- }
- }
-
- if (Scopes.empty())
- continue;
-
- if (isPoolDrain(Scopes.back().PoolVar, child)) {
- PoolScope &scope = Scopes.back();
- scope.End = I;
- handlePoolScope(scope, S);
- Scopes.pop_back();
- }
- }
- return true;
- }
-
-private:
- void clearUnavailableDiags(Stmt *S) {
- if (S)
- Pass.TA.clearDiagnostic(diag::err_unavailable,
- diag::err_unavailable_message,
- S->getSourceRange());
- }
-
- struct PoolScope {
- VarDecl *PoolVar;
- CompoundStmt *CompoundParent;
- Stmt::child_iterator Begin;
- Stmt::child_iterator End;
- bool IsFollowedBySimpleReturnStmt;
- SmallVector<ObjCMessageExpr *, 4> Releases;
-
- PoolScope()
- : PoolVar(nullptr), CompoundParent(nullptr),
- IsFollowedBySimpleReturnStmt(false) {}
-
- SourceRange getIndentedRange() const {
- Stmt::child_iterator rangeS = Begin;
- ++rangeS;
- if (rangeS == End)
- return SourceRange();
- Stmt::child_iterator rangeE = Begin;
- for (Stmt::child_iterator I = rangeS; I != End; ++I)
- ++rangeE;
- return SourceRange((*rangeS)->getBeginLoc(), (*rangeE)->getEndLoc());
- }
- };
-
- class NameReferenceChecker : public RecursiveASTVisitor<NameReferenceChecker>{
- ASTContext &Ctx;
- SourceRange ScopeRange;
- SourceLocation &referenceLoc, &declarationLoc;
-
- public:
- NameReferenceChecker(ASTContext &ctx, PoolScope &scope,
- SourceLocation &referenceLoc,
- SourceLocation &declarationLoc)
- : Ctx(ctx), referenceLoc(referenceLoc),
- declarationLoc(declarationLoc) {
- ScopeRange = SourceRange((*scope.Begin)->getBeginLoc(),
- (*scope.End)->getBeginLoc());
- }
-
- bool VisitDeclRefExpr(DeclRefExpr *E) {
- return checkRef(E->getLocation(), E->getDecl()->getLocation());
- }
-
- bool VisitTypedefTypeLoc(TypedefTypeLoc TL) {
- return checkRef(TL.getBeginLoc(), TL.getTypedefNameDecl()->getLocation());
- }
-
- bool VisitTagTypeLoc(TagTypeLoc TL) {
- return checkRef(TL.getBeginLoc(), TL.getDecl()->getLocation());
- }
-
- private:
- bool checkRef(SourceLocation refLoc, SourceLocation declLoc) {
- if (isInScope(declLoc)) {
- referenceLoc = refLoc;
- declarationLoc = declLoc;
- return false;
- }
- return true;
- }
-
- bool isInScope(SourceLocation loc) {
- if (loc.isInvalid())
- return false;
-
- SourceManager &SM = Ctx.getSourceManager();
- if (SM.isBeforeInTranslationUnit(loc, ScopeRange.getBegin()))
- return false;
- return SM.isBeforeInTranslationUnit(loc, ScopeRange.getEnd());
- }
- };
-
- void handlePoolScope(PoolScope &scope, CompoundStmt *compoundS) {
- // Check that all names declared inside the scope are not used
- // outside the scope.
- {
- bool nameUsedOutsideScope = false;
- SourceLocation referenceLoc, declarationLoc;
- Stmt::child_iterator SI = scope.End, SE = compoundS->body_end();
- ++SI;
- // Check if the autoreleasepool scope is followed by a simple return
- // statement, in which case we will include the return in the scope.
- if (SI != SE)
- if (ReturnStmt *retS = dyn_cast<ReturnStmt>(*SI))
- if ((retS->getRetValue() == nullptr ||
- isa<DeclRefExpr>(retS->getRetValue()->IgnoreParenCasts())) &&
- findLocationAfterSemi(retS->getEndLoc(), Pass.Ctx).isValid()) {
- scope.IsFollowedBySimpleReturnStmt = true;
- ++SI; // the return will be included in scope, don't check it.
- }
-
- for (; SI != SE; ++SI) {
- nameUsedOutsideScope = !NameReferenceChecker(Pass.Ctx, scope,
- referenceLoc,
- declarationLoc).TraverseStmt(*SI);
- if (nameUsedOutsideScope)
- break;
- }
-
- // If not all references were cleared it means some variables/typenames/etc
- // declared inside the pool scope are used outside of it.
- // We won't try to rewrite the pool.
- if (nameUsedOutsideScope) {
- Pass.TA.reportError("a name is referenced outside the "
- "NSAutoreleasePool scope that it was declared in", referenceLoc);
- Pass.TA.reportNote("name declared here", declarationLoc);
- Pass.TA.reportNote("intended @autoreleasepool scope begins here",
- (*scope.Begin)->getBeginLoc());
- Pass.TA.reportNote("intended @autoreleasepool scope ends here",
- (*scope.End)->getBeginLoc());
- return;
- }
- }
-
- // Collect all releases of the pool; they will be removed.
- {
- ReleaseCollector releaseColl(scope.PoolVar, scope.Releases);
- Stmt::child_iterator I = scope.Begin;
- ++I;
- for (; I != scope.End; ++I)
- releaseColl.TraverseStmt(*I);
- }
-
- PoolVars[scope.PoolVar].Scopes.push_back(scope);
- }
-
- bool isPoolCreation(Expr *E) {
- if (!E) return false;
- E = getEssential(E);
- ObjCMessageExpr *ME = dyn_cast<ObjCMessageExpr>(E);
- if (!ME) return false;
- if (ME->getMethodFamily() == OMF_new &&
- ME->getReceiverKind() == ObjCMessageExpr::Class &&
- isNSAutoreleasePool(ME->getReceiverInterface()))
- return true;
- if (ME->getReceiverKind() == ObjCMessageExpr::Instance &&
- ME->getMethodFamily() == OMF_init) {
- Expr *rec = getEssential(ME->getInstanceReceiver());
- if (ObjCMessageExpr *recME = dyn_cast_or_null<ObjCMessageExpr>(rec)) {
- if (recME->getMethodFamily() == OMF_alloc &&
- recME->getReceiverKind() == ObjCMessageExpr::Class &&
- isNSAutoreleasePool(recME->getReceiverInterface()))
- return true;
- }
- }
-
- return false;
- }
-
- bool isPoolDrain(VarDecl *poolVar, Stmt *S) {
- if (!S) return false;
- S = getEssential(S);
- ObjCMessageExpr *ME = dyn_cast<ObjCMessageExpr>(S);
- if (!ME) return false;
- if (ME->getReceiverKind() == ObjCMessageExpr::Instance) {
- Expr *rec = getEssential(ME->getInstanceReceiver());
- if (DeclRefExpr *dref = dyn_cast<DeclRefExpr>(rec))
- if (dref->getDecl() == poolVar)
- return ME->getMethodFamily() == OMF_release ||
- ME->getSelector() == DrainSel;
- }
-
- return false;
- }
-
- bool isNSAutoreleasePool(ObjCInterfaceDecl *IDecl) {
- return IDecl && IDecl->getIdentifier() == PoolII;
- }
-
- bool isNSAutoreleasePool(QualType Ty) {
- QualType pointee = Ty->getPointeeType();
- if (pointee.isNull())
- return false;
- if (const ObjCInterfaceType *interT = pointee->getAs<ObjCInterfaceType>())
- return isNSAutoreleasePool(interT->getDecl());
- return false;
- }
-
- static Expr *getEssential(Expr *E) {
- return cast<Expr>(getEssential((Stmt*)E));
- }
- static Stmt *getEssential(Stmt *S) {
- if (FullExpr *FE = dyn_cast<FullExpr>(S))
- S = FE->getSubExpr();
- if (Expr *E = dyn_cast<Expr>(S))
- S = E->IgnoreParenCasts();
- return S;
- }
-
- Stmt *Body;
- MigrationPass &Pass;
-
- IdentifierInfo *PoolII;
- Selector DrainSel;
-
- struct PoolVarInfo {
- DeclStmt *Dcl = nullptr;
- ExprSet Refs;
- SmallVector<PoolScope, 2> Scopes;
-
- PoolVarInfo() = default;
- };
-
- std::map<VarDecl *, PoolVarInfo> PoolVars;
-};
-
-} // anonymous namespace
-
-void trans::rewriteAutoreleasePool(MigrationPass &pass) {
- BodyTransform<AutoreleasePoolRewriter> trans(pass);
- trans.TraverseDecl(pass.Ctx.getTranslationUnitDecl());
-}
diff --git a/clang/lib/ARCMigrate/TransBlockObjCVariable.cpp b/clang/lib/ARCMigrate/TransBlockObjCVariable.cpp
deleted file mode 100644
index 1e4db33135b6a1..00000000000000
--- a/clang/lib/ARCMigrate/TransBlockObjCVariable.cpp
+++ /dev/null
@@ -1,146 +0,0 @@
-//===--- TransBlockObjCVariable.cpp - Transformations to ARC mode ---------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-//
-// rewriteBlockObjCVariable:
-//
-// Adding __block to an obj-c variable could be either because the variable
-// is used for output storage or the user wanted to break a retain cycle.
-// This transformation checks whether a reference of the variable for the block
-// is actually needed (it is assigned to or its address is taken) or not.
-// If the reference is not needed it will assume __block was added to break a
-// cycle so it will remove '__block' and add __weak/__unsafe_unretained.
-// e.g
-//
-// __block Foo *x;
-// bar(^ { [x cake]; });
-// ---->
-// __weak Foo *x;
-// bar(^ { [x cake]; });
-//
-//===----------------------------------------------------------------------===//
-
-#include "Transforms.h"
-#include "Internals.h"
-#include "clang/AST/ASTContext.h"
-#include "clang/AST/Attr.h"
-#include "clang/Basic/SourceManager.h"
-
-using namespace clang;
-using namespace arcmt;
-using namespace trans;
-
-namespace {
-
-class RootBlockObjCVarRewriter :
- public RecursiveASTVisitor<RootBlockObjCVarRewriter> {
- llvm::DenseSet<VarDecl *> &VarsToChange;
-
- class BlockVarChecker : public RecursiveASTVisitor<BlockVarChecker> {
- VarDecl *Var;
-
- typedef RecursiveASTVisitor<BlockVarChecker> base;
- public:
- BlockVarChecker(VarDecl *var) : Var(var) { }
-
- bool TraverseImplicitCastExpr(ImplicitCastExpr *castE) {
- if (DeclRefExpr *
- ref = dyn_cast<DeclRefExpr>(castE->getSubExpr())) {
- if (ref->getDecl() == Var) {
- if (castE->getCastKind() == CK_LValueToRValue)
- return true; // Using the value of the variable.
- if (castE->getCastKind() == CK_NoOp && castE->isLValue() &&
- Var->getASTContext().getLangOpts().CPlusPlus)
- return true; // Binding to const C++ reference.
- }
- }
-
- return base::TraverseImplicitCastExpr(castE);
- }
-
- bool VisitDeclRefExpr(DeclRefExpr *E) {
- if (E->getDecl() == Var)
- return false; // The reference of the variable, and not just its value,
- // is needed.
- return true;
- }
- };
-
-public:
- RootBlockObjCVarRewriter(llvm::DenseSet<VarDecl *> &VarsToChange)
- : VarsToChange(VarsToChange) { }
-
- bool VisitBlockDecl(BlockDecl *block) {
- SmallVector<VarDecl *, 4> BlockVars;
-
- for (const auto &I : block->captures()) {
- VarDecl *var = I.getVariable();
- if (I.isByRef() &&
- var->getType()->isObjCObjectPointerType() &&
- isImplicitStrong(var->getType())) {
- BlockVars.push_back(var);
- }
- }
-
- for (unsigned i = 0, e = BlockVars.size(); i != e; ++i) {
- VarDecl *var = BlockVars[i];
-
- BlockVarChecker checker(var);
- bool onlyValueOfVarIsNeeded = checker.TraverseStmt(block->getBody());
- if (onlyValueOfVarIsNeeded)
- VarsToChange.insert(var);
- else
- VarsToChange.erase(var);
- }
-
- return true;
- }
-
-private:
- bool isImplicitStrong(QualType ty) {
- if (isa<AttributedType>(ty.getTypePtr()))
- return false;
- return ty.getLocalQualifiers().getObjCLifetime() == Qualifiers::OCL_Strong;
- }
-};
-
-class BlockObjCVarRewriter : public RecursiveASTVisitor<BlockObjCVarRewriter> {
- llvm::DenseSet<VarDecl *> &VarsToChange;
-
-public:
- BlockObjCVarRewriter(llvm::DenseSet<VarDecl *> &VarsToChange)
- : VarsToChange(VarsToChange) { }
-
- bool TraverseBlockDecl(BlockDecl *block) {
- RootBlockObjCVarRewriter(VarsToChange).TraverseDecl(block);
- return true;
- }
-};
-
-} // anonymous namespace
-
-void BlockObjCVariableTraverser::traverseBody(BodyContext &BodyCtx) {
- MigrationPass &Pass = BodyCtx.getMigrationContext().Pass;
- llvm::DenseSet<VarDecl *> VarsToChange;
-
- BlockObjCVarRewriter trans(VarsToChange);
- trans.TraverseStmt(BodyCtx.getTopStmt());
-
- for (llvm::DenseSet<VarDecl *>::iterator
- I = VarsToChange.begin(), E = VarsToChange.end(); I != E; ++I) {
- VarDecl *var = *I;
- BlocksAttr *attr = var->getAttr<BlocksAttr>();
- if(!attr)
- continue;
- bool useWeak = canApplyWeak(Pass.Ctx, var->getType());
- SourceManager &SM = Pass.Ctx.getSourceManager();
- Transaction Trans(Pass.TA);
- Pass.TA.replaceText(SM.getExpansionLoc(attr->getLocation()),
- "__block",
- useWeak ? "__weak" : "__unsafe_unretained");
- }
-}
diff --git a/clang/lib/ARCMigrate/TransEmptyStatementsAndDealloc.cpp b/clang/lib/ARCMigrate/TransEmptyStatementsAndDealloc.cpp
deleted file mode 100644
index e9c21b8106d7dd..00000000000000
--- a/clang/lib/ARCMigrate/TransEmptyStatementsAndDealloc.cpp
+++ /dev/null
@@ -1,249 +0,0 @@
-//===-- TransEmptyStatementsAndDealloc.cpp - Transformations to ARC mode --===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-//
-// removeEmptyStatementsAndDealloc:
-//
-// Removes empty statements that are leftovers from previous transformations.
-// e.g for
-//
-// [x retain];
-//
-// removeRetainReleaseDealloc will leave an empty ";" that removeEmptyStatements
-// will remove.
-//
-//===----------------------------------------------------------------------===//
-
-#include "Transforms.h"
-#include "Internals.h"
-#include "clang/AST/ASTContext.h"
-#include "clang/AST/StmtVisitor.h"
-#include "clang/Basic/SourceManager.h"
-
-using namespace clang;
-using namespace arcmt;
-using namespace trans;
-
-static bool isEmptyARCMTMacroStatement(NullStmt *S,
- std::vector<SourceLocation> &MacroLocs,
- ASTContext &Ctx) {
- if (!S->hasLeadingEmptyMacro())
- return false;
-
- SourceLocation SemiLoc = S->getSemiLoc();
- if (SemiLoc.isInvalid() || SemiLoc.isMacroID())
- return false;
-
- if (MacroLocs.empty())
- return false;
-
- SourceManager &SM = Ctx.getSourceManager();
- std::vector<SourceLocation>::iterator I = llvm::upper_bound(
- MacroLocs, SemiLoc, BeforeThanCompare<SourceLocation>(SM));
- --I;
- SourceLocation
- AfterMacroLoc = I->getLocWithOffset(getARCMTMacroName().size());
- assert(AfterMacroLoc.isFileID());
-
- if (AfterMacroLoc == SemiLoc)
- return true;
-
- SourceLocation::IntTy RelOffs = 0;
- if (!SM.isInSameSLocAddrSpace(AfterMacroLoc, SemiLoc, &RelOffs))
- return false;
- if (RelOffs < 0)
- return false;
-
- // We make the reasonable assumption that a semicolon after 100 characters
- // means that it is not the next token after our macro. If this assumption
- // fails it is not critical, we will just fail to clear out, e.g., an empty
- // 'if'.
- if (RelOffs - getARCMTMacroName().size() > 100)
- return false;
-
- SourceLocation AfterMacroSemiLoc = findSemiAfterLocation(AfterMacroLoc, Ctx);
- return AfterMacroSemiLoc == SemiLoc;
-}
-
-namespace {
-
-/// Returns true if the statement became empty due to previous
-/// transformations.
-class EmptyChecker : public StmtVisitor<EmptyChecker, bool> {
- ASTContext &Ctx;
- std::vector<SourceLocation> &MacroLocs;
-
-public:
- EmptyChecker(ASTContext &ctx, std::vector<SourceLocation> ¯oLocs)
- : Ctx(ctx), MacroLocs(macroLocs) { }
-
- bool VisitNullStmt(NullStmt *S) {
- return isEmptyARCMTMacroStatement(S, MacroLocs, Ctx);
- }
- bool VisitCompoundStmt(CompoundStmt *S) {
- if (S->body_empty())
- return false; // was already empty, not because of transformations.
- for (auto *I : S->body())
- if (!Visit(I))
- return false;
- return true;
- }
- bool VisitIfStmt(IfStmt *S) {
- if (S->getConditionVariable())
- return false;
- Expr *condE = S->getCond();
- if (!condE)
- return false;
- if (hasSideEffects(condE, Ctx))
- return false;
- if (!S->getThen() || !Visit(S->getThen()))
- return false;
- return !S->getElse() || Visit(S->getElse());
- }
- bool VisitWhileStmt(WhileStmt *S) {
- if (S->getConditionVariable())
- return false;
- Expr *condE = S->getCond();
- if (!condE)
- return false;
- if (hasSideEffects(condE, Ctx))
- return false;
- if (!S->getBody())
- return false;
- return Visit(S->getBody());
- }
- bool VisitDoStmt(DoStmt *S) {
- Expr *condE = S->getCond();
- if (!condE)
- return false;
- if (hasSideEffects(condE, Ctx))
- return false;
- if (!S->getBody())
- return false;
- return Visit(S->getBody());
- }
- bool VisitObjCForCollectionStmt(ObjCForCollectionStmt *S) {
- Expr *Exp = S->getCollection();
- if (!Exp)
- return false;
- if (hasSideEffects(Exp, Ctx))
- return false;
- if (!S->getBody())
- return false;
- return Visit(S->getBody());
- }
- bool VisitObjCAutoreleasePoolStmt(ObjCAutoreleasePoolStmt *S) {
- if (!S->getSubStmt())
- return false;
- return Visit(S->getSubStmt());
- }
-};
-
-class EmptyStatementsRemover :
- public RecursiveASTVisitor<EmptyStatementsRemover> {
- MigrationPass &Pass;
-
-public:
- EmptyStatementsRemover(MigrationPass &pass) : Pass(pass) { }
-
- bool TraverseStmtExpr(StmtExpr *E) {
- CompoundStmt *S = E->getSubStmt();
- for (CompoundStmt::body_iterator
- I = S->body_begin(), E = S->body_end(); I != E; ++I) {
- if (I != E - 1)
- check(*I);
- TraverseStmt(*I);
- }
- return true;
- }
-
- bool VisitCompoundStmt(CompoundStmt *S) {
- for (auto *I : S->body())
- check(I);
- return true;
- }
-
- ASTContext &getContext() { return Pass.Ctx; }
-
-private:
- void check(Stmt *S) {
- if (!S) return;
- if (EmptyChecker(Pass.Ctx, Pass.ARCMTMacroLocs).Visit(S)) {
- Transaction Trans(Pass.TA);
- Pass.TA.removeStmt(S);
- }
- }
-};
-
-} // anonymous namespace
-
-static bool isBodyEmpty(CompoundStmt *body, ASTContext &Ctx,
- std::vector<SourceLocation> &MacroLocs) {
- for (auto *I : body->body())
- if (!EmptyChecker(Ctx, MacroLocs).Visit(I))
- return false;
-
- return true;
-}
-
-static void cleanupDeallocOrFinalize(MigrationPass &pass) {
- ASTContext &Ctx = pass.Ctx;
- TransformActions &TA = pass.TA;
- DeclContext *DC = Ctx.getTranslationUnitDecl();
- Selector FinalizeSel =
- Ctx.Selectors.getNullarySelector(&pass.Ctx.Idents.get("finalize"));
-
- typedef DeclContext::specific_decl_iterator<ObjCImplementationDecl>
- impl_iterator;
- for (impl_iterator I = impl_iterator(DC->decls_begin()),
- E = impl_iterator(DC->decls_end()); I != E; ++I) {
- ObjCMethodDecl *DeallocM = nullptr;
- ObjCMethodDecl *FinalizeM = nullptr;
- for (auto *MD : I->instance_methods()) {
- if (!MD->hasBody())
- continue;
-
- if (MD->getMethodFamily() == OMF_dealloc) {
- DeallocM = MD;
- } else if (MD->isInstanceMethod() && MD->getSelector() == FinalizeSel) {
- FinalizeM = MD;
- }
- }
-
- if (DeallocM) {
- if (isBodyEmpty(DeallocM->getCompoundBody(), Ctx, pass.ARCMTMacroLocs)) {
- Transaction Trans(TA);
- TA.remove(DeallocM->getSourceRange());
- }
-
- if (FinalizeM) {
- Transaction Trans(TA);
- TA.remove(FinalizeM->getSourceRange());
- }
-
- } else if (FinalizeM) {
- if (isBodyEmpty(FinalizeM->getCompoundBody(), Ctx, pass.ARCMTMacroLocs)) {
- Transaction Trans(TA);
- TA.remove(FinalizeM->getSourceRange());
- } else {
- Transaction Trans(TA);
- TA.replaceText(FinalizeM->getSelectorStartLoc(), "finalize", "dealloc");
- }
- }
- }
-}
-
-void trans::removeEmptyStatementsAndDeallocFinalize(MigrationPass &pass) {
- EmptyStatementsRemover(pass).TraverseDecl(pass.Ctx.getTranslationUnitDecl());
-
- cleanupDeallocOrFinalize(pass);
-
- for (unsigned i = 0, e = pass.ARCMTMacroLocs.size(); i != e; ++i) {
- Transaction Trans(pass.TA);
- pass.TA.remove(pass.ARCMTMacroLocs[i]);
- }
-}
diff --git a/clang/lib/ARCMigrate/TransGCAttrs.cpp b/clang/lib/ARCMigrate/TransGCAttrs.cpp
deleted file mode 100644
index 85e3fe77660b5c..00000000000000
--- a/clang/lib/ARCMigrate/TransGCAttrs.cpp
+++ /dev/null
@@ -1,350 +0,0 @@
-//===--- TransGCAttrs.cpp - Transformations to ARC mode -------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#include "Transforms.h"
-#include "Internals.h"
-#include "clang/AST/ASTContext.h"
-#include "clang/Basic/SourceManager.h"
-#include "clang/Lex/Lexer.h"
-#include "clang/Sema/SemaDiagnostic.h"
-#include "llvm/ADT/SmallString.h"
-#include "llvm/ADT/TinyPtrVector.h"
-#include "llvm/Support/SaveAndRestore.h"
-
-using namespace clang;
-using namespace arcmt;
-using namespace trans;
-
-namespace {
-
-/// Collects all the places where GC attributes __strong/__weak occur.
-class GCAttrsCollector : public RecursiveASTVisitor<GCAttrsCollector> {
- MigrationContext &MigrateCtx;
- bool FullyMigratable;
- std::vector<ObjCPropertyDecl *> &AllProps;
-
- typedef RecursiveASTVisitor<GCAttrsCollector> base;
-public:
- GCAttrsCollector(MigrationContext &ctx,
- std::vector<ObjCPropertyDecl *> &AllProps)
- : MigrateCtx(ctx), FullyMigratable(false),
- AllProps(AllProps) { }
-
- bool shouldWalkTypesOfTypeLocs() const { return false; }
-
- bool VisitAttributedTypeLoc(AttributedTypeLoc TL) {
- handleAttr(TL);
- return true;
- }
-
- bool TraverseDecl(Decl *D) {
- if (!D || D->isImplicit())
- return true;
-
- SaveAndRestore Save(FullyMigratable, isMigratable(D));
-
- if (ObjCPropertyDecl *PropD = dyn_cast<ObjCPropertyDecl>(D)) {
- lookForAttribute(PropD, PropD->getTypeSourceInfo());
- AllProps.push_back(PropD);
- } else if (DeclaratorDecl *DD = dyn_cast<DeclaratorDecl>(D)) {
- lookForAttribute(DD, DD->getTypeSourceInfo());
- }
- return base::TraverseDecl(D);
- }
-
- void lookForAttribute(Decl *D, TypeSourceInfo *TInfo) {
- if (!TInfo)
- return;
- TypeLoc TL = TInfo->getTypeLoc();
- while (TL) {
- if (QualifiedTypeLoc QL = TL.getAs<QualifiedTypeLoc>()) {
- TL = QL.getUnqualifiedLoc();
- } else if (AttributedTypeLoc Attr = TL.getAs<AttributedTypeLoc>()) {
- if (handleAttr(Attr, D))
- break;
- TL = Attr.getModifiedLoc();
- } else if (MacroQualifiedTypeLoc MDTL =
- TL.getAs<MacroQualifiedTypeLoc>()) {
- TL = MDTL.getInnerLoc();
- } else if (ArrayTypeLoc Arr = TL.getAs<ArrayTypeLoc>()) {
- TL = Arr.getElementLoc();
- } else if (PointerTypeLoc PT = TL.getAs<PointerTypeLoc>()) {
- TL = PT.getPointeeLoc();
- } else if (ReferenceTypeLoc RT = TL.getAs<ReferenceTypeLoc>())
- TL = RT.getPointeeLoc();
- else
- break;
- }
- }
-
- bool handleAttr(AttributedTypeLoc TL, Decl *D = nullptr) {
- auto *OwnershipAttr = TL.getAttrAs<ObjCOwnershipAttr>();
- if (!OwnershipAttr)
- return false;
-
- SourceLocation Loc = OwnershipAttr->getLocation();
- SourceLocation OrigLoc = Loc;
- if (MigrateCtx.AttrSet.count(OrigLoc))
- return true;
-
- ASTContext &Ctx = MigrateCtx.Pass.Ctx;
- SourceManager &SM = Ctx.getSourceManager();
- if (Loc.isMacroID())
- Loc = SM.getImmediateExpansionRange(Loc).getBegin();
- StringRef Spell = OwnershipAttr->getKind()->getName();
- MigrationContext::GCAttrOccurrence::AttrKind Kind;
- if (Spell == "strong")
- Kind = MigrationContext::GCAttrOccurrence::Strong;
- else if (Spell == "weak")
- Kind = MigrationContext::GCAttrOccurrence::Weak;
- else
- return false;
-
- MigrateCtx.AttrSet.insert(OrigLoc);
- MigrateCtx.GCAttrs.push_back(MigrationContext::GCAttrOccurrence());
- MigrationContext::GCAttrOccurrence &Attr = MigrateCtx.GCAttrs.back();
-
- Attr.Kind = Kind;
- Attr.Loc = Loc;
- Attr.ModifiedType = TL.getModifiedLoc().getType();
- Attr.Dcl = D;
- Attr.FullyMigratable = FullyMigratable;
- return true;
- }
-
- bool isMigratable(Decl *D) {
- if (isa<TranslationUnitDecl>(D))
- return false;
-
- if (isInMainFile(D))
- return true;
-
- if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D))
- return FD->hasBody();
-
- if (ObjCContainerDecl *ContD = dyn_cast<ObjCContainerDecl>(D))
- return hasObjCImpl(ContD);
-
- if (CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(D)) {
- for (const auto *MI : RD->methods()) {
- if (MI->isOutOfLine())
- return true;
- }
- return false;
- }
-
- return isMigratable(cast<Decl>(D->getDeclContext()));
- }
-
- static bool hasObjCImpl(Decl *D) {
- if (!D)
- return false;
- if (ObjCContainerDecl *ContD = dyn_cast<ObjCContainerDecl>(D)) {
- if (ObjCInterfaceDecl *ID = dyn_cast<ObjCInterfaceDecl>(ContD))
- return ID->getImplementation() != nullptr;
- if (ObjCCategoryDecl *CD = dyn_cast<ObjCCategoryDecl>(ContD))
- return CD->getImplementation() != nullptr;
- return isa<ObjCImplDecl>(ContD);
- }
- return false;
- }
-
- bool isInMainFile(Decl *D) {
- if (!D)
- return false;
-
- for (auto *I : D->redecls())
- if (!isInMainFile(I->getLocation()))
- return false;
-
- return true;
- }
-
- bool isInMainFile(SourceLocation Loc) {
- if (Loc.isInvalid())
- return false;
-
- SourceManager &SM = MigrateCtx.Pass.Ctx.getSourceManager();
- return SM.isInFileID(SM.getExpansionLoc(Loc), SM.getMainFileID());
- }
-};
-
-} // anonymous namespace
-
-static void errorForGCAttrsOnNonObjC(MigrationContext &MigrateCtx) {
- TransformActions &TA = MigrateCtx.Pass.TA;
-
- for (unsigned i = 0, e = MigrateCtx.GCAttrs.size(); i != e; ++i) {
- MigrationContext::GCAttrOccurrence &Attr = MigrateCtx.GCAttrs[i];
- if (Attr.FullyMigratable && Attr.Dcl) {
- if (Attr.ModifiedType.isNull())
- continue;
- if (!Attr.ModifiedType->isObjCRetainableType()) {
- TA.reportError("GC managed memory will become unmanaged in ARC",
- Attr.Loc);
- }
- }
- }
-}
-
-static void checkWeakGCAttrs(MigrationContext &MigrateCtx) {
- TransformActions &TA = MigrateCtx.Pass.TA;
-
- for (unsigned i = 0, e = MigrateCtx.GCAttrs.size(); i != e; ++i) {
- MigrationContext::GCAttrOccurrence &Attr = MigrateCtx.GCAttrs[i];
- if (Attr.Kind == MigrationContext::GCAttrOccurrence::Weak) {
- if (Attr.ModifiedType.isNull() ||
- !Attr.ModifiedType->isObjCRetainableType())
- continue;
- if (!canApplyWeak(MigrateCtx.Pass.Ctx, Attr.ModifiedType,
- /*AllowOnUnknownClass=*/true)) {
- Transaction Trans(TA);
- if (!MigrateCtx.RemovedAttrSet.count(Attr.Loc))
- TA.replaceText(Attr.Loc, "__weak", "__unsafe_unretained");
- TA.clearDiagnostic(diag::err_arc_weak_no_runtime,
- diag::err_arc_unsupported_weak_class,
- Attr.Loc);
- }
- }
- }
-}
-
-typedef llvm::TinyPtrVector<ObjCPropertyDecl *> IndivPropsTy;
-
-static void checkAllAtProps(MigrationContext &MigrateCtx,
- SourceLocation AtLoc,
- IndivPropsTy &IndProps) {
- if (IndProps.empty())
- return;
-
- for (IndivPropsTy::iterator
- PI = IndProps.begin(), PE = IndProps.end(); PI != PE; ++PI) {
- QualType T = (*PI)->getType();
- if (T.isNull() || !T->isObjCRetainableType())
- return;
- }
-
- SmallVector<std::pair<AttributedTypeLoc, ObjCPropertyDecl *>, 4> ATLs;
- bool hasWeak = false, hasStrong = false;
- ObjCPropertyAttribute::Kind Attrs = ObjCPropertyAttribute::kind_noattr;
- for (IndivPropsTy::iterator
- PI = IndProps.begin(), PE = IndProps.end(); PI != PE; ++PI) {
- ObjCPropertyDecl *PD = *PI;
- Attrs = PD->getPropertyAttributesAsWritten();
- TypeSourceInfo *TInfo = PD->getTypeSourceInfo();
- if (!TInfo)
- return;
- TypeLoc TL = TInfo->getTypeLoc();
- if (AttributedTypeLoc ATL =
- TL.getAs<AttributedTypeLoc>()) {
- ATLs.push_back(std::make_pair(ATL, PD));
- if (TInfo->getType().getObjCLifetime() == Qualifiers::OCL_Weak) {
- hasWeak = true;
- } else if (TInfo->getType().getObjCLifetime() == Qualifiers::OCL_Strong)
- hasStrong = true;
- else
- return;
- }
- }
- if (ATLs.empty())
- return;
- if (hasWeak && hasStrong)
- return;
-
- TransformActions &TA = MigrateCtx.Pass.TA;
- Transaction Trans(TA);
-
- if (GCAttrsCollector::hasObjCImpl(
- cast<Decl>(IndProps.front()->getDeclContext()))) {
- if (hasWeak)
- MigrateCtx.AtPropsWeak.insert(AtLoc);
-
- } else {
- StringRef toAttr = "strong";
- if (hasWeak) {
- if (canApplyWeak(MigrateCtx.Pass.Ctx, IndProps.front()->getType(),
- /*AllowOnUnknownClass=*/true))
- toAttr = "weak";
- else
- toAttr = "unsafe_unretained";
- }
- if (Attrs & ObjCPropertyAttribute::kind_assign)
- MigrateCtx.rewritePropertyAttribute("assign", toAttr, AtLoc);
- else
- MigrateCtx.addPropertyAttribute(toAttr, AtLoc);
- }
-
- for (unsigned i = 0, e = ATLs.size(); i != e; ++i) {
- SourceLocation Loc = ATLs[i].first.getAttr()->getLocation();
- if (Loc.isMacroID())
- Loc = MigrateCtx.Pass.Ctx.getSourceManager()
- .getImmediateExpansionRange(Loc)
- .getBegin();
- TA.remove(Loc);
- TA.clearDiagnostic(diag::err_objc_property_attr_mutually_exclusive, AtLoc);
- TA.clearDiagnostic(diag::err_arc_inconsistent_property_ownership,
- ATLs[i].second->getLocation());
- MigrateCtx.RemovedAttrSet.insert(Loc);
- }
-}
-
-static void checkAllProps(MigrationContext &MigrateCtx,
- std::vector<ObjCPropertyDecl *> &AllProps) {
- typedef llvm::TinyPtrVector<ObjCPropertyDecl *> IndivPropsTy;
- llvm::DenseMap<SourceLocation, IndivPropsTy> AtProps;
-
- for (unsigned i = 0, e = AllProps.size(); i != e; ++i) {
- ObjCPropertyDecl *PD = AllProps[i];
- if (PD->getPropertyAttributesAsWritten() &
- (ObjCPropertyAttribute::kind_assign |
- ObjCPropertyAttribute::kind_readonly)) {
- SourceLocation AtLoc = PD->getAtLoc();
- if (AtLoc.isInvalid())
- continue;
- AtProps[AtLoc].push_back(PD);
- }
- }
-
- for (auto I = AtProps.begin(), E = AtProps.end(); I != E; ++I) {
- SourceLocation AtLoc = I->first;
- IndivPropsTy &IndProps = I->second;
- checkAllAtProps(MigrateCtx, AtLoc, IndProps);
- }
-}
-
-void GCAttrsTraverser::traverseTU(MigrationContext &MigrateCtx) {
- std::vector<ObjCPropertyDecl *> AllProps;
- GCAttrsCollector(MigrateCtx, AllProps).TraverseDecl(
- MigrateCtx.Pass.Ctx.getTranslationUnitDecl());
-
- errorForGCAttrsOnNonObjC(MigrateCtx);
- checkAllProps(MigrateCtx, AllProps);
- checkWeakGCAttrs(MigrateCtx);
-}
-
-void MigrationContext::dumpGCAttrs() {
- llvm::errs() << "\n################\n";
- for (unsigned i = 0, e = GCAttrs.size(); i != e; ++i) {
- GCAttrOccurrence &Attr = GCAttrs[i];
- llvm::errs() << "KIND: "
- << (Attr.Kind == GCAttrOccurrence::Strong ? "strong" : "weak");
- llvm::errs() << "\nLOC: ";
- Attr.Loc.print(llvm::errs(), Pass.Ctx.getSourceManager());
- llvm::errs() << "\nTYPE: ";
- Attr.ModifiedType.dump();
- if (Attr.Dcl) {
- llvm::errs() << "DECL:\n";
- Attr.Dcl->dump();
- } else {
- llvm::errs() << "DECL: NONE";
- }
- llvm::errs() << "\nMIGRATABLE: " << Attr.FullyMigratable;
- llvm::errs() << "\n----------------\n";
- }
- llvm::errs() << "\n################\n";
-}
diff --git a/clang/lib/ARCMigrate/TransGCCalls.cpp b/clang/lib/ARCMigrate/TransGCCalls.cpp
deleted file mode 100644
index 43233e2d0b456a..00000000000000
--- a/clang/lib/ARCMigrate/TransGCCalls.cpp
+++ /dev/null
@@ -1,76 +0,0 @@
-//===--- TransGCCalls.cpp - Transformations to ARC mode -------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#include "Transforms.h"
-#include "Internals.h"
-#include "clang/AST/ASTContext.h"
-#include "clang/Sema/SemaDiagnostic.h"
-
-using namespace clang;
-using namespace arcmt;
-using namespace trans;
-
-namespace {
-
-class GCCollectableCallsChecker :
- public RecursiveASTVisitor<GCCollectableCallsChecker> {
- MigrationContext &MigrateCtx;
- IdentifierInfo *NSMakeCollectableII;
- IdentifierInfo *CFMakeCollectableII;
-
-public:
- GCCollectableCallsChecker(MigrationContext &ctx)
- : MigrateCtx(ctx) {
- IdentifierTable &Ids = MigrateCtx.Pass.Ctx.Idents;
- NSMakeCollectableII = &Ids.get("NSMakeCollectable");
- CFMakeCollectableII = &Ids.get("CFMakeCollectable");
- }
-
- bool shouldWalkTypesOfTypeLocs() const { return false; }
-
- bool VisitCallExpr(CallExpr *E) {
- TransformActions &TA = MigrateCtx.Pass.TA;
-
- if (MigrateCtx.isGCOwnedNonObjC(E->getType())) {
- TA.report(E->getBeginLoc(), diag::warn_arcmt_nsalloc_realloc,
- E->getSourceRange());
- return true;
- }
-
- Expr *CEE = E->getCallee()->IgnoreParenImpCasts();
- if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(CEE)) {
- if (FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(DRE->getDecl())) {
- if (!FD->getDeclContext()->getRedeclContext()->isFileContext())
- return true;
-
- if (FD->getIdentifier() == NSMakeCollectableII) {
- Transaction Trans(TA);
- TA.clearDiagnostic(diag::err_unavailable,
- diag::err_unavailable_message,
- diag::err_ovl_deleted_call, // ObjC++
- DRE->getSourceRange());
- TA.replace(DRE->getSourceRange(), "CFBridgingRelease");
-
- } else if (FD->getIdentifier() == CFMakeCollectableII) {
- TA.reportError("CFMakeCollectable will leak the object that it "
- "receives in ARC", DRE->getLocation(),
- DRE->getSourceRange());
- }
- }
- }
-
- return true;
- }
-};
-
-} // anonymous namespace
-
-void GCCollectableCallsTraverser::traverseBody(BodyContext &BodyCtx) {
- GCCollectableCallsChecker(BodyCtx.getMigrationContext())
- .TraverseStmt(BodyCtx.getTopStmt());
-}
diff --git a/clang/lib/ARCMigrate/TransProperties.cpp b/clang/lib/ARCMigrate/TransProperties.cpp
deleted file mode 100644
index 6d1d950821a07c..00000000000000
--- a/clang/lib/ARCMigrate/TransProperties.cpp
+++ /dev/null
@@ -1,379 +0,0 @@
-//===--- TransProperties.cpp - Transformations to ARC mode ----------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-//
-// rewriteProperties:
-//
-// - Adds strong/weak/unsafe_unretained ownership specifier to properties that
-// are missing one.
-// - Migrates properties from (retain) to (strong) and (assign) to
-// (unsafe_unretained/weak).
-// - If a property is synthesized, adds the ownership specifier in the ivar
-// backing the property.
-//
-// @interface Foo : NSObject {
-// NSObject *x;
-// }
-// @property (assign) id x;
-// @end
-// ---->
-// @interface Foo : NSObject {
-// NSObject *__weak x;
-// }
-// @property (weak) id x;
-// @end
-//
-//===----------------------------------------------------------------------===//
-
-#include "Transforms.h"
-#include "Internals.h"
-#include "clang/Basic/SourceManager.h"
-#include "clang/Lex/Lexer.h"
-#include "clang/Sema/SemaDiagnostic.h"
-#include <map>
-
-using namespace clang;
-using namespace arcmt;
-using namespace trans;
-
-namespace {
-
-class PropertiesRewriter {
- MigrationContext &MigrateCtx;
- MigrationPass &Pass;
- ObjCImplementationDecl *CurImplD = nullptr;
-
- enum PropActionKind {
- PropAction_None,
- PropAction_RetainReplacedWithStrong,
- PropAction_AssignRemoved,
- PropAction_AssignRewritten,
- PropAction_MaybeAddWeakOrUnsafe
- };
-
- struct PropData {
- ObjCPropertyDecl *PropD;
- ObjCIvarDecl *IvarD;
- ObjCPropertyImplDecl *ImplD;
-
- PropData(ObjCPropertyDecl *propD)
- : PropD(propD), IvarD(nullptr), ImplD(nullptr) {}
- };
-
- typedef SmallVector<PropData, 2> PropsTy;
- typedef std::map<SourceLocation, PropsTy> AtPropDeclsTy;
- AtPropDeclsTy AtProps;
- llvm::DenseMap<IdentifierInfo *, PropActionKind> ActionOnProp;
-
-public:
- explicit PropertiesRewriter(MigrationContext &MigrateCtx)
- : MigrateCtx(MigrateCtx), Pass(MigrateCtx.Pass) { }
-
- static void collectProperties(ObjCContainerDecl *D, AtPropDeclsTy &AtProps,
- AtPropDeclsTy *PrevAtProps = nullptr) {
- for (auto *Prop : D->instance_properties()) {
- SourceLocation Loc = Prop->getAtLoc();
- if (Loc.isInvalid())
- continue;
- if (PrevAtProps)
- if (PrevAtProps->find(Loc) != PrevAtProps->end())
- continue;
- PropsTy &props = AtProps[Loc];
- props.push_back(Prop);
- }
- }
-
- void doTransform(ObjCImplementationDecl *D) {
- CurImplD = D;
- ObjCInterfaceDecl *iface = D->getClassInterface();
- if (!iface)
- return;
-
- collectProperties(iface, AtProps);
-
- // Look through extensions.
- for (auto *Ext : iface->visible_extensions())
- collectProperties(Ext, AtProps);
-
- typedef DeclContext::specific_decl_iterator<ObjCPropertyImplDecl>
- prop_impl_iterator;
- for (prop_impl_iterator
- I = prop_impl_iterator(D->decls_begin()),
- E = prop_impl_iterator(D->decls_end()); I != E; ++I) {
- ObjCPropertyImplDecl *implD = *I;
- if (implD->getPropertyImplementation() != ObjCPropertyImplDecl::Synthesize)
- continue;
- ObjCPropertyDecl *propD = implD->getPropertyDecl();
- if (!propD || propD->isInvalidDecl())
- continue;
- ObjCIvarDecl *ivarD = implD->getPropertyIvarDecl();
- if (!ivarD || ivarD->isInvalidDecl())
- continue;
- AtPropDeclsTy::iterator findAtLoc = AtProps.find(propD->getAtLoc());
- if (findAtLoc == AtProps.end())
- continue;
-
- PropsTy &props = findAtLoc->second;
- for (PropsTy::iterator I = props.begin(), E = props.end(); I != E; ++I) {
- if (I->PropD == propD) {
- I->IvarD = ivarD;
- I->ImplD = implD;
- break;
- }
- }
- }
-
- for (AtPropDeclsTy::iterator
- I = AtProps.begin(), E = AtProps.end(); I != E; ++I) {
- SourceLocation atLoc = I->first;
- PropsTy &props = I->second;
- if (!getPropertyType(props)->isObjCRetainableType())
- continue;
- if (hasIvarWithExplicitARCOwnership(props))
- continue;
-
- Transaction Trans(Pass.TA);
- rewriteProperty(props, atLoc);
- }
- }
-
-private:
- void doPropAction(PropActionKind kind,
- PropsTy &props, SourceLocation atLoc,
- bool markAction = true) {
- if (markAction)
- for (PropsTy::iterator I = props.begin(), E = props.end(); I != E; ++I)
- ActionOnProp[I->PropD->getIdentifier()] = kind;
-
- switch (kind) {
- case PropAction_None:
- return;
- case PropAction_RetainReplacedWithStrong: {
- StringRef toAttr = "strong";
- MigrateCtx.rewritePropertyAttribute("retain", toAttr, atLoc);
- return;
- }
- case PropAction_AssignRemoved:
- return removeAssignForDefaultStrong(props, atLoc);
- case PropAction_AssignRewritten:
- return rewriteAssign(props, atLoc);
- case PropAction_MaybeAddWeakOrUnsafe:
- return maybeAddWeakOrUnsafeUnretainedAttr(props, atLoc);
- }
- }
-
- void rewriteProperty(PropsTy &props, SourceLocation atLoc) {
- ObjCPropertyAttribute::Kind propAttrs = getPropertyAttrs(props);
-
- if (propAttrs &
- (ObjCPropertyAttribute::kind_copy |
- ObjCPropertyAttribute::kind_unsafe_unretained |
- ObjCPropertyAttribute::kind_strong | ObjCPropertyAttribute::kind_weak))
- return;
-
- if (propAttrs & ObjCPropertyAttribute::kind_retain) {
- // strong is the default.
- return doPropAction(PropAction_RetainReplacedWithStrong, props, atLoc);
- }
-
- bool HasIvarAssignedAPlusOneObject = hasIvarAssignedAPlusOneObject(props);
-
- if (propAttrs & ObjCPropertyAttribute::kind_assign) {
- if (HasIvarAssignedAPlusOneObject)
- return doPropAction(PropAction_AssignRemoved, props, atLoc);
- return doPropAction(PropAction_AssignRewritten, props, atLoc);
- }
-
- if (HasIvarAssignedAPlusOneObject ||
- (Pass.isGCMigration() && !hasGCWeak(props, atLoc)))
- return; // 'strong' by default.
-
- return doPropAction(PropAction_MaybeAddWeakOrUnsafe, props, atLoc);
- }
-
- void removeAssignForDefaultStrong(PropsTy &props,
- SourceLocation atLoc) const {
- removeAttribute("retain", atLoc);
- if (!removeAttribute("assign", atLoc))
- return;
-
- for (PropsTy::iterator I = props.begin(), E = props.end(); I != E; ++I) {
- if (I->ImplD)
- Pass.TA.clearDiagnostic(diag::err_arc_strong_property_ownership,
- diag::err_arc_assign_property_ownership,
- diag::err_arc_inconsistent_property_ownership,
- I->IvarD->getLocation());
- }
- }
-
- void rewriteAssign(PropsTy &props, SourceLocation atLoc) const {
- bool canUseWeak = canApplyWeak(Pass.Ctx, getPropertyType(props),
- /*AllowOnUnknownClass=*/Pass.isGCMigration());
- const char *toWhich =
- (Pass.isGCMigration() && !hasGCWeak(props, atLoc)) ? "strong" :
- (canUseWeak ? "weak" : "unsafe_unretained");
-
- bool rewroteAttr = rewriteAttribute("assign", toWhich, atLoc);
- if (!rewroteAttr)
- canUseWeak = false;
-
- for (PropsTy::iterator I = props.begin(), E = props.end(); I != E; ++I) {
- if (isUserDeclared(I->IvarD)) {
- if (I->IvarD &&
- I->IvarD->getType().getObjCLifetime() != Qualifiers::OCL_Weak) {
- const char *toWhich =
- (Pass.isGCMigration() && !hasGCWeak(props, atLoc)) ? "__strong " :
- (canUseWeak ? "__weak " : "__unsafe_unretained ");
- Pass.TA.insert(I->IvarD->getLocation(), toWhich);
- }
- }
- if (I->ImplD)
- Pass.TA.clearDiagnostic(diag::err_arc_strong_property_ownership,
- diag::err_arc_assign_property_ownership,
- diag::err_arc_inconsistent_property_ownership,
- I->IvarD->getLocation());
- }
- }
-
- void maybeAddWeakOrUnsafeUnretainedAttr(PropsTy &props,
- SourceLocation atLoc) const {
- bool canUseWeak = canApplyWeak(Pass.Ctx, getPropertyType(props),
- /*AllowOnUnknownClass=*/Pass.isGCMigration());
-
- bool addedAttr = addAttribute(canUseWeak ? "weak" : "unsafe_unretained",
- atLoc);
- if (!addedAttr)
- canUseWeak = false;
-
- for (PropsTy::iterator I = props.begin(), E = props.end(); I != E; ++I) {
- if (isUserDeclared(I->IvarD)) {
- if (I->IvarD &&
- I->IvarD->getType().getObjCLifetime() != Qualifiers::OCL_Weak)
- Pass.TA.insert(I->IvarD->getLocation(),
- canUseWeak ? "__weak " : "__unsafe_unretained ");
- }
- if (I->ImplD) {
- Pass.TA.clearDiagnostic(diag::err_arc_strong_property_ownership,
- diag::err_arc_assign_property_ownership,
- diag::err_arc_inconsistent_property_ownership,
- I->IvarD->getLocation());
- Pass.TA.clearDiagnostic(
- diag::err_arc_objc_property_default_assign_on_object,
- I->ImplD->getLocation());
- }
- }
- }
-
- bool removeAttribute(StringRef fromAttr, SourceLocation atLoc) const {
- return MigrateCtx.removePropertyAttribute(fromAttr, atLoc);
- }
-
- bool rewriteAttribute(StringRef fromAttr, StringRef toAttr,
- SourceLocation atLoc) const {
- return MigrateCtx.rewritePropertyAttribute(fromAttr, toAttr, atLoc);
- }
-
- bool addAttribute(StringRef attr, SourceLocation atLoc) const {
- return MigrateCtx.addPropertyAttribute(attr, atLoc);
- }
-
- class PlusOneAssign : public RecursiveASTVisitor<PlusOneAssign> {
- ObjCIvarDecl *Ivar;
- public:
- PlusOneAssign(ObjCIvarDecl *D) : Ivar(D) {}
-
- bool VisitBinaryOperator(BinaryOperator *E) {
- if (E->getOpcode() != BO_Assign)
- return true;
-
- Expr *lhs = E->getLHS()->IgnoreParenImpCasts();
- if (ObjCIvarRefExpr *RE = dyn_cast<ObjCIvarRefExpr>(lhs)) {
- if (RE->getDecl() != Ivar)
- return true;
-
- if (isPlusOneAssign(E))
- return false;
- }
-
- return true;
- }
- };
-
- bool hasIvarAssignedAPlusOneObject(PropsTy &props) const {
- for (PropsTy::iterator I = props.begin(), E = props.end(); I != E; ++I) {
- PlusOneAssign oneAssign(I->IvarD);
- bool notFound = oneAssign.TraverseDecl(CurImplD);
- if (!notFound)
- return true;
- }
-
- return false;
- }
-
- bool hasIvarWithExplicitARCOwnership(PropsTy &props) const {
- if (Pass.isGCMigration())
- return false;
-
- for (PropsTy::iterator I = props.begin(), E = props.end(); I != E; ++I) {
- if (isUserDeclared(I->IvarD)) {
- if (isa<AttributedType>(I->IvarD->getType()))
- return true;
- if (I->IvarD->getType().getLocalQualifiers().getObjCLifetime()
- != Qualifiers::OCL_Strong)
- return true;
- }
- }
-
- return false;
- }
-
- // Returns true if all declarations in the @property have GC __weak.
- bool hasGCWeak(PropsTy &props, SourceLocation atLoc) const {
- if (!Pass.isGCMigration())
- return false;
- if (props.empty())
- return false;
- return MigrateCtx.AtPropsWeak.count(atLoc);
- }
-
- bool isUserDeclared(ObjCIvarDecl *ivarD) const {
- return ivarD && !ivarD->getSynthesize();
- }
-
- QualType getPropertyType(PropsTy &props) const {
- assert(!props.empty());
- QualType ty = props[0].PropD->getType().getUnqualifiedType();
-
-#ifndef NDEBUG
- for (PropsTy::iterator I = props.begin(), E = props.end(); I != E; ++I)
- assert(ty == I->PropD->getType().getUnqualifiedType());
-#endif
-
- return ty;
- }
-
- ObjCPropertyAttribute::Kind getPropertyAttrs(PropsTy &props) const {
- assert(!props.empty());
- ObjCPropertyAttribute::Kind attrs =
- props[0].PropD->getPropertyAttributesAsWritten();
-
-#ifndef NDEBUG
- for (PropsTy::iterator I = props.begin(), E = props.end(); I != E; ++I)
- assert(attrs == I->PropD->getPropertyAttributesAsWritten());
-#endif
-
- return attrs;
- }
-};
-
-} // anonymous namespace
-
-void PropertyRewriteTraverser::traverseObjCImplementation(
- ObjCImplementationContext &ImplCtx) {
- PropertiesRewriter(ImplCtx.getMigrationContext())
- .doTransform(ImplCtx.getImplementationDecl());
-}
diff --git a/clang/lib/ARCMigrate/TransProtectedScope.cpp b/clang/lib/ARCMigrate/TransProtectedScope.cpp
deleted file mode 100644
index 154e0b54800f99..00000000000000
--- a/clang/lib/ARCMigrate/TransProtectedScope.cpp
+++ /dev/null
@@ -1,203 +0,0 @@
-//===--- TransProtectedScope.cpp - Transformations to ARC mode ------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-//
-// Adds brackets in case statements that "contain" initialization of retaining
-// variable, thus emitting the "switch case is in protected scope" error.
-//
-//===----------------------------------------------------------------------===//
-
-#include "Internals.h"
-#include "Transforms.h"
-#include "clang/AST/ASTContext.h"
-#include "clang/Basic/SourceManager.h"
-#include "clang/Sema/SemaDiagnostic.h"
-
-using namespace clang;
-using namespace arcmt;
-using namespace trans;
-
-namespace {
-
-class LocalRefsCollector : public RecursiveASTVisitor<LocalRefsCollector> {
- SmallVectorImpl<DeclRefExpr *> &Refs;
-
-public:
- LocalRefsCollector(SmallVectorImpl<DeclRefExpr *> &refs)
- : Refs(refs) { }
-
- bool VisitDeclRefExpr(DeclRefExpr *E) {
- if (ValueDecl *D = E->getDecl())
- if (D->getDeclContext()->getRedeclContext()->isFunctionOrMethod())
- Refs.push_back(E);
- return true;
- }
-};
-
-struct CaseInfo {
- SwitchCase *SC;
- SourceRange Range;
- enum {
- St_Unchecked,
- St_CannotFix,
- St_Fixed
- } State;
-
- CaseInfo() : SC(nullptr), State(St_Unchecked) {}
- CaseInfo(SwitchCase *S, SourceRange Range)
- : SC(S), Range(Range), State(St_Unchecked) {}
-};
-
-class CaseCollector : public RecursiveASTVisitor<CaseCollector> {
- ParentMap &PMap;
- SmallVectorImpl<CaseInfo> &Cases;
-
-public:
- CaseCollector(ParentMap &PMap, SmallVectorImpl<CaseInfo> &Cases)
- : PMap(PMap), Cases(Cases) { }
-
- bool VisitSwitchStmt(SwitchStmt *S) {
- SwitchCase *Curr = S->getSwitchCaseList();
- if (!Curr)
- return true;
- Stmt *Parent = getCaseParent(Curr);
- Curr = Curr->getNextSwitchCase();
- // Make sure all case statements are in the same scope.
- while (Curr) {
- if (getCaseParent(Curr) != Parent)
- return true;
- Curr = Curr->getNextSwitchCase();
- }
-
- SourceLocation NextLoc = S->getEndLoc();
- Curr = S->getSwitchCaseList();
- // We iterate over case statements in reverse source-order.
- while (Curr) {
- Cases.push_back(
- CaseInfo(Curr, SourceRange(Curr->getBeginLoc(), NextLoc)));
- NextLoc = Curr->getBeginLoc();
- Curr = Curr->getNextSwitchCase();
- }
- return true;
- }
-
- Stmt *getCaseParent(SwitchCase *S) {
- Stmt *Parent = PMap.getParent(S);
- while (Parent && (isa<SwitchCase>(Parent) || isa<LabelStmt>(Parent)))
- Parent = PMap.getParent(Parent);
- return Parent;
- }
-};
-
-class ProtectedScopeFixer {
- MigrationPass &Pass;
- SourceManager &SM;
- SmallVector<CaseInfo, 16> Cases;
- SmallVector<DeclRefExpr *, 16> LocalRefs;
-
-public:
- ProtectedScopeFixer(BodyContext &BodyCtx)
- : Pass(BodyCtx.getMigrationContext().Pass),
- SM(Pass.Ctx.getSourceManager()) {
-
- CaseCollector(BodyCtx.getParentMap(), Cases)
- .TraverseStmt(BodyCtx.getTopStmt());
- LocalRefsCollector(LocalRefs).TraverseStmt(BodyCtx.getTopStmt());
-
- SourceRange BodyRange = BodyCtx.getTopStmt()->getSourceRange();
- const CapturedDiagList &DiagList = Pass.getDiags();
- // Copy the diagnostics so we don't have to worry about invaliding iterators
- // from the diagnostic list.
- SmallVector<StoredDiagnostic, 16> StoredDiags;
- StoredDiags.append(DiagList.begin(), DiagList.end());
- SmallVectorImpl<StoredDiagnostic>::iterator
- I = StoredDiags.begin(), E = StoredDiags.end();
- while (I != E) {
- if (I->getID() == diag::err_switch_into_protected_scope &&
- isInRange(I->getLocation(), BodyRange)) {
- handleProtectedScopeError(I, E);
- continue;
- }
- ++I;
- }
- }
-
- void handleProtectedScopeError(
- SmallVectorImpl<StoredDiagnostic>::iterator &DiagI,
- SmallVectorImpl<StoredDiagnostic>::iterator DiagE){
- Transaction Trans(Pass.TA);
- assert(DiagI->getID() == diag::err_switch_into_protected_scope);
- SourceLocation ErrLoc = DiagI->getLocation();
- bool handledAllNotes = true;
- ++DiagI;
- for (; DiagI != DiagE && DiagI->getLevel() == DiagnosticsEngine::Note;
- ++DiagI) {
- if (!handleProtectedNote(*DiagI))
- handledAllNotes = false;
- }
-
- if (handledAllNotes)
- Pass.TA.clearDiagnostic(diag::err_switch_into_protected_scope, ErrLoc);
- }
-
- bool handleProtectedNote(const StoredDiagnostic &Diag) {
- assert(Diag.getLevel() == DiagnosticsEngine::Note);
-
- for (unsigned i = 0; i != Cases.size(); i++) {
- CaseInfo &info = Cases[i];
- if (isInRange(Diag.getLocation(), info.Range)) {
-
- if (info.State == CaseInfo::St_Unchecked)
- tryFixing(info);
- assert(info.State != CaseInfo::St_Unchecked);
-
- if (info.State == CaseInfo::St_Fixed) {
- Pass.TA.clearDiagnostic(Diag.getID(), Diag.getLocation());
- return true;
- }
- return false;
- }
- }
-
- return false;
- }
-
- void tryFixing(CaseInfo &info) {
- assert(info.State == CaseInfo::St_Unchecked);
- if (hasVarReferencedOutside(info)) {
- info.State = CaseInfo::St_CannotFix;
- return;
- }
-
- Pass.TA.insertAfterToken(info.SC->getColonLoc(), " {");
- Pass.TA.insert(info.Range.getEnd(), "}\n");
- info.State = CaseInfo::St_Fixed;
- }
-
- bool hasVarReferencedOutside(CaseInfo &info) {
- for (unsigned i = 0, e = LocalRefs.size(); i != e; ++i) {
- DeclRefExpr *DRE = LocalRefs[i];
- if (isInRange(DRE->getDecl()->getLocation(), info.Range) &&
- !isInRange(DRE->getLocation(), info.Range))
- return true;
- }
- return false;
- }
-
- bool isInRange(SourceLocation Loc, SourceRange R) {
- if (Loc.isInvalid())
- return false;
- return !SM.isBeforeInTranslationUnit(Loc, R.getBegin()) &&
- SM.isBeforeInTranslationUnit(Loc, R.getEnd());
- }
-};
-
-} // anonymous namespace
-
-void ProtectedScopeTraverser::traverseBody(BodyContext &BodyCtx) {
- ProtectedScopeFixer Fix(BodyCtx);
-}
diff --git a/clang/lib/ARCMigrate/TransRetainReleaseDealloc.cpp b/clang/lib/ARCMigrate/TransRetainReleaseDealloc.cpp
deleted file mode 100644
index baa503d8a39dc1..00000000000000
--- a/clang/lib/ARCMigrate/TransRetainReleaseDealloc.cpp
+++ /dev/null
@@ -1,459 +0,0 @@
-//===--- TransRetainReleaseDealloc.cpp - Transformations to ARC mode ------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-//
-// removeRetainReleaseDealloc:
-//
-// Removes retain/release/autorelease/dealloc messages.
-//
-// return [[foo retain] autorelease];
-// ---->
-// return foo;
-//
-//===----------------------------------------------------------------------===//
-
-#include "Transforms.h"
-#include "Internals.h"
-#include "clang/AST/ASTContext.h"
-#include "clang/AST/ParentMap.h"
-#include "clang/Basic/SourceManager.h"
-#include "clang/Lex/Lexer.h"
-#include "clang/Sema/SemaDiagnostic.h"
-#include "llvm/ADT/StringSwitch.h"
-
-using namespace clang;
-using namespace arcmt;
-using namespace trans;
-
-namespace {
-
-class RetainReleaseDeallocRemover :
- public RecursiveASTVisitor<RetainReleaseDeallocRemover> {
- Stmt *Body;
- MigrationPass &Pass;
-
- ExprSet Removables;
- std::unique_ptr<ParentMap> StmtMap;
-
- Selector DelegateSel, FinalizeSel;
-
-public:
- RetainReleaseDeallocRemover(MigrationPass &pass)
- : Body(nullptr), Pass(pass) {
- DelegateSel =
- Pass.Ctx.Selectors.getNullarySelector(&Pass.Ctx.Idents.get("delegate"));
- FinalizeSel =
- Pass.Ctx.Selectors.getNullarySelector(&Pass.Ctx.Idents.get("finalize"));
- }
-
- void transformBody(Stmt *body, Decl *ParentD) {
- Body = body;
- collectRemovables(body, Removables);
- StmtMap.reset(new ParentMap(body));
- TraverseStmt(body);
- }
-
- bool VisitObjCMessageExpr(ObjCMessageExpr *E) {
- switch (E->getMethodFamily()) {
- default:
- if (E->isInstanceMessage() && E->getSelector() == FinalizeSel)
- break;
- return true;
- case OMF_autorelease:
- if (isRemovable(E)) {
- if (!isCommonUnusedAutorelease(E)) {
- // An unused autorelease is badness. If we remove it the receiver
- // will likely die immediately while previously it was kept alive
- // by the autorelease pool. This is bad practice in general, leave it
- // and emit an error to force the user to restructure their code.
- Pass.TA.reportError(
- "it is not safe to remove an unused 'autorelease' "
- "message; its receiver may be destroyed immediately",
- E->getBeginLoc(), E->getSourceRange());
- return true;
- }
- }
- // Pass through.
- [[fallthrough]];
- case OMF_retain:
- case OMF_release:
- if (E->getReceiverKind() == ObjCMessageExpr::Instance)
- if (Expr *rec = E->getInstanceReceiver()) {
- rec = rec->IgnoreParenImpCasts();
- if (rec->getType().getObjCLifetime() == Qualifiers::OCL_ExplicitNone &&
- (E->getMethodFamily() != OMF_retain || isRemovable(E))) {
- std::string err = "it is not safe to remove '";
- err += E->getSelector().getAsString() + "' message on "
- "an __unsafe_unretained type";
- Pass.TA.reportError(err, rec->getBeginLoc());
- return true;
- }
-
- if (isGlobalVar(rec) &&
- (E->getMethodFamily() != OMF_retain || isRemovable(E))) {
- std::string err = "it is not safe to remove '";
- err += E->getSelector().getAsString() + "' message on "
- "a global variable";
- Pass.TA.reportError(err, rec->getBeginLoc());
- return true;
- }
-
- if (E->getMethodFamily() == OMF_release && isDelegateMessage(rec)) {
- Pass.TA.reportError(
- "it is not safe to remove 'retain' "
- "message on the result of a 'delegate' message; "
- "the object that was passed to 'setDelegate:' may not be "
- "properly retained",
- rec->getBeginLoc());
- return true;
- }
- }
- break;
- case OMF_dealloc:
- break;
- }
-
- switch (E->getReceiverKind()) {
- default:
- return true;
- case ObjCMessageExpr::SuperInstance: {
- Transaction Trans(Pass.TA);
- clearDiagnostics(E->getSelectorLoc(0));
- if (tryRemoving(E))
- return true;
- Pass.TA.replace(E->getSourceRange(), "self");
- return true;
- }
- case ObjCMessageExpr::Instance:
- break;
- }
-
- Expr *rec = E->getInstanceReceiver();
- if (!rec) return true;
-
- Transaction Trans(Pass.TA);
- clearDiagnostics(E->getSelectorLoc(0));
-
- ObjCMessageExpr *Msg = E;
- Expr *RecContainer = Msg;
- SourceRange RecRange = rec->getSourceRange();
- checkForGCDOrXPC(Msg, RecContainer, rec, RecRange);
-
- if (Msg->getMethodFamily() == OMF_release &&
- isRemovable(RecContainer) && isInAtFinally(RecContainer)) {
- // Change the -release to "receiver = nil" in a finally to avoid a leak
- // when an exception is thrown.
- Pass.TA.replace(RecContainer->getSourceRange(), RecRange);
- std::string str = " = ";
- str += getNilString(Pass);
- Pass.TA.insertAfterToken(RecRange.getEnd(), str);
- return true;
- }
-
- if (hasSideEffects(rec, Pass.Ctx) || !tryRemoving(RecContainer))
- Pass.TA.replace(RecContainer->getSourceRange(), RecRange);
-
- return true;
- }
-
-private:
- /// Checks for idioms where an unused -autorelease is common.
- ///
- /// Returns true for this idiom which is common in property
- /// setters:
- ///
- /// [backingValue autorelease];
- /// backingValue = [newValue retain]; // in general a +1 assign
- ///
- /// For these as well:
- ///
- /// [[var retain] autorelease];
- /// return var;
- ///
- bool isCommonUnusedAutorelease(ObjCMessageExpr *E) {
- return isPlusOneAssignBeforeOrAfterAutorelease(E) ||
- isReturnedAfterAutorelease(E);
- }
-
- bool isReturnedAfterAutorelease(ObjCMessageExpr *E) {
- Expr *Rec = E->getInstanceReceiver();
- if (!Rec)
- return false;
-
- Decl *RefD = getReferencedDecl(Rec);
- if (!RefD)
- return false;
-
- Stmt *nextStmt = getNextStmt(E);
- if (!nextStmt)
- return false;
-
- // Check for "return <variable>;".
-
- if (ReturnStmt *RetS = dyn_cast<ReturnStmt>(nextStmt))
- return RefD == getReferencedDecl(RetS->getRetValue());
-
- return false;
- }
-
- bool isPlusOneAssignBeforeOrAfterAutorelease(ObjCMessageExpr *E) {
- Expr *Rec = E->getInstanceReceiver();
- if (!Rec)
- return false;
-
- Decl *RefD = getReferencedDecl(Rec);
- if (!RefD)
- return false;
-
- Stmt *prevStmt, *nextStmt;
- std::tie(prevStmt, nextStmt) = getPreviousAndNextStmt(E);
-
- return isPlusOneAssignToVar(prevStmt, RefD) ||
- isPlusOneAssignToVar(nextStmt, RefD);
- }
-
- bool isPlusOneAssignToVar(Stmt *S, Decl *RefD) {
- if (!S)
- return false;
-
- // Check for "RefD = [+1 retained object];".
-
- if (BinaryOperator *Bop = dyn_cast<BinaryOperator>(S)) {
- return (RefD == getReferencedDecl(Bop->getLHS())) && isPlusOneAssign(Bop);
- }
-
- if (DeclStmt *DS = dyn_cast<DeclStmt>(S)) {
- if (DS->isSingleDecl() && DS->getSingleDecl() == RefD) {
- if (VarDecl *VD = dyn_cast<VarDecl>(RefD))
- return isPlusOne(VD->getInit());
- }
- return false;
- }
-
- return false;
- }
-
- Stmt *getNextStmt(Expr *E) {
- return getPreviousAndNextStmt(E).second;
- }
-
- std::pair<Stmt *, Stmt *> getPreviousAndNextStmt(Expr *E) {
- Stmt *prevStmt = nullptr, *nextStmt = nullptr;
- if (!E)
- return std::make_pair(prevStmt, nextStmt);
-
- Stmt *OuterS = E, *InnerS;
- do {
- InnerS = OuterS;
- OuterS = StmtMap->getParent(InnerS);
- }
- while (OuterS && (isa<ParenExpr>(OuterS) ||
- isa<CastExpr>(OuterS) ||
- isa<FullExpr>(OuterS)));
-
- if (!OuterS)
- return std::make_pair(prevStmt, nextStmt);
-
- Stmt::child_iterator currChildS = OuterS->child_begin();
- Stmt::child_iterator childE = OuterS->child_end();
- Stmt::child_iterator prevChildS = childE;
- for (; currChildS != childE; ++currChildS) {
- if (*currChildS == InnerS)
- break;
- prevChildS = currChildS;
- }
-
- if (prevChildS != childE) {
- prevStmt = *prevChildS;
- if (auto *E = dyn_cast_or_null<Expr>(prevStmt))
- prevStmt = E->IgnoreImplicit();
- }
-
- if (currChildS == childE)
- return std::make_pair(prevStmt, nextStmt);
- ++currChildS;
- if (currChildS == childE)
- return std::make_pair(prevStmt, nextStmt);
-
- nextStmt = *currChildS;
- if (auto *E = dyn_cast_or_null<Expr>(nextStmt))
- nextStmt = E->IgnoreImplicit();
-
- return std::make_pair(prevStmt, nextStmt);
- }
-
- Decl *getReferencedDecl(Expr *E) {
- if (!E)
- return nullptr;
-
- E = E->IgnoreParenCasts();
- if (ObjCMessageExpr *ME = dyn_cast<ObjCMessageExpr>(E)) {
- switch (ME->getMethodFamily()) {
- case OMF_copy:
- case OMF_autorelease:
- case OMF_release:
- case OMF_retain:
- return getReferencedDecl(ME->getInstanceReceiver());
- default:
- return nullptr;
- }
- }
- if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E))
- return DRE->getDecl();
- if (MemberExpr *ME = dyn_cast<MemberExpr>(E))
- return ME->getMemberDecl();
- if (ObjCIvarRefExpr *IRE = dyn_cast<ObjCIvarRefExpr>(E))
- return IRE->getDecl();
-
- return nullptr;
- }
-
- /// Check if the retain/release is due to a GCD/XPC macro that are
- /// defined as:
- ///
- /// #define dispatch_retain(object) ({ dispatch_object_t _o = (object); _dispatch_object_validate(_o); (void)[_o retain]; })
- /// #define dispatch_release(object) ({ dispatch_object_t _o = (object); _dispatch_object_validate(_o); [_o release]; })
- /// #define xpc_retain(object) ({ xpc_object_t _o = (object); _xpc_object_validate(_o); [_o retain]; })
- /// #define xpc_release(object) ({ xpc_object_t _o = (object); _xpc_object_validate(_o); [_o release]; })
- ///
- /// and return the top container which is the StmtExpr and the macro argument
- /// expression.
- void checkForGCDOrXPC(ObjCMessageExpr *Msg, Expr *&RecContainer,
- Expr *&Rec, SourceRange &RecRange) {
- SourceLocation Loc = Msg->getExprLoc();
- if (!Loc.isMacroID())
- return;
- SourceManager &SM = Pass.Ctx.getSourceManager();
- StringRef MacroName = Lexer::getImmediateMacroName(Loc, SM,
- Pass.Ctx.getLangOpts());
- bool isGCDOrXPC = llvm::StringSwitch<bool>(MacroName)
- .Case("dispatch_retain", true)
- .Case("dispatch_release", true)
- .Case("xpc_retain", true)
- .Case("xpc_release", true)
- .Default(false);
- if (!isGCDOrXPC)
- return;
-
- StmtExpr *StmtE = nullptr;
- Stmt *S = Msg;
- while (S) {
- if (StmtExpr *SE = dyn_cast<StmtExpr>(S)) {
- StmtE = SE;
- break;
- }
- S = StmtMap->getParent(S);
- }
-
- if (!StmtE)
- return;
-
- Stmt::child_range StmtExprChild = StmtE->children();
- if (StmtExprChild.begin() == StmtExprChild.end())
- return;
- auto *CompS = dyn_cast_or_null<CompoundStmt>(*StmtExprChild.begin());
- if (!CompS)
- return;
-
- Stmt::child_range CompStmtChild = CompS->children();
- if (CompStmtChild.begin() == CompStmtChild.end())
- return;
- auto *DeclS = dyn_cast_or_null<DeclStmt>(*CompStmtChild.begin());
- if (!DeclS)
- return;
- if (!DeclS->isSingleDecl())
- return;
- VarDecl *VD = dyn_cast_or_null<VarDecl>(DeclS->getSingleDecl());
- if (!VD)
- return;
- Expr *Init = VD->getInit();
- if (!Init)
- return;
-
- RecContainer = StmtE;
- Rec = Init->IgnoreParenImpCasts();
- if (FullExpr *FE = dyn_cast<FullExpr>(Rec))
- Rec = FE->getSubExpr()->IgnoreParenImpCasts();
- RecRange = Rec->getSourceRange();
- if (SM.isMacroArgExpansion(RecRange.getBegin()))
- RecRange.setBegin(SM.getImmediateSpellingLoc(RecRange.getBegin()));
- if (SM.isMacroArgExpansion(RecRange.getEnd()))
- RecRange.setEnd(SM.getImmediateSpellingLoc(RecRange.getEnd()));
- }
-
- void clearDiagnostics(SourceLocation loc) const {
- Pass.TA.clearDiagnostic(diag::err_arc_illegal_explicit_message,
- diag::err_unavailable,
- diag::err_unavailable_message,
- loc);
- }
-
- bool isDelegateMessage(Expr *E) const {
- if (!E) return false;
-
- E = E->IgnoreParenCasts();
-
- // Also look through property-getter sugar.
- if (PseudoObjectExpr *pseudoOp = dyn_cast<PseudoObjectExpr>(E))
- E = pseudoOp->getResultExpr()->IgnoreImplicit();
-
- if (ObjCMessageExpr *ME = dyn_cast<ObjCMessageExpr>(E))
- return (ME->isInstanceMessage() && ME->getSelector() == DelegateSel);
-
- return false;
- }
-
- bool isInAtFinally(Expr *E) const {
- assert(E);
- Stmt *S = E;
- while (S) {
- if (isa<ObjCAtFinallyStmt>(S))
- return true;
- S = StmtMap->getParent(S);
- }
-
- return false;
- }
-
- bool isRemovable(Expr *E) const {
- return Removables.count(E);
- }
-
- bool tryRemoving(Expr *E) const {
- if (isRemovable(E)) {
- Pass.TA.removeStmt(E);
- return true;
- }
-
- Stmt *parent = StmtMap->getParent(E);
-
- if (ImplicitCastExpr *castE = dyn_cast_or_null<ImplicitCastExpr>(parent))
- return tryRemoving(castE);
-
- if (ParenExpr *parenE = dyn_cast_or_null<ParenExpr>(parent))
- return tryRemoving(parenE);
-
- if (BinaryOperator *
- bopE = dyn_cast_or_null<BinaryOperator>(parent)) {
- if (bopE->getOpcode() == BO_Comma && bopE->getLHS() == E &&
- isRemovable(bopE)) {
- Pass.TA.replace(bopE->getSourceRange(), bopE->getRHS()->getSourceRange());
- return true;
- }
- }
-
- return false;
- }
-
-};
-
-} // anonymous namespace
-
-void trans::removeRetainReleaseDeallocFinalize(MigrationPass &pass) {
- BodyTransform<RetainReleaseDeallocRemover> trans(pass);
- trans.TraverseDecl(pass.Ctx.getTranslationUnitDecl());
-}
diff --git a/clang/lib/ARCMigrate/TransUnbridgedCasts.cpp b/clang/lib/ARCMigrate/TransUnbridgedCasts.cpp
deleted file mode 100644
index 7390ea17c8a4b6..00000000000000
--- a/clang/lib/ARCMigrate/TransUnbridgedCasts.cpp
+++ /dev/null
@@ -1,466 +0,0 @@
-//===--- TransUnbridgedCasts.cpp - Transformations to ARC mode ------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-//
-// rewriteUnbridgedCasts:
-//
-// A cast of non-objc pointer to an objc one is checked. If the non-objc pointer
-// is from a file-level variable, __bridge cast is used to convert it.
-// For the result of a function call that we know is +1/+0,
-// __bridge/CFBridgingRelease is used.
-//
-// NSString *str = (NSString *)kUTTypePlainText;
-// str = b ? kUTTypeRTF : kUTTypePlainText;
-// NSString *_uuidString = (NSString *)CFUUIDCreateString(kCFAllocatorDefault,
-// _uuid);
-// ---->
-// NSString *str = (__bridge NSString *)kUTTypePlainText;
-// str = (__bridge NSString *)(b ? kUTTypeRTF : kUTTypePlainText);
-// NSString *_uuidString = (NSString *)
-// CFBridgingRelease(CFUUIDCreateString(kCFAllocatorDefault, _uuid));
-//
-// For a C pointer to ObjC, for casting 'self', __bridge is used.
-//
-// CFStringRef str = (CFStringRef)self;
-// ---->
-// CFStringRef str = (__bridge CFStringRef)self;
-//
-// Uses of Block_copy/Block_release macros are rewritten:
-//
-// c = Block_copy(b);
-// Block_release(c);
-// ---->
-// c = [b copy];
-// <removed>
-//
-//===----------------------------------------------------------------------===//
-
-#include "Transforms.h"
-#include "Internals.h"
-#include "clang/AST/ASTContext.h"
-#include "clang/AST/Attr.h"
-#include "clang/AST/ParentMap.h"
-#include "clang/Analysis/DomainSpecific/CocoaConventions.h"
-#include "clang/Basic/SourceManager.h"
-#include "clang/Lex/Lexer.h"
-#include "clang/Sema/SemaDiagnostic.h"
-#include "llvm/ADT/SmallString.h"
-
-using namespace clang;
-using namespace arcmt;
-using namespace trans;
-
-namespace {
-
-class UnbridgedCastRewriter : public RecursiveASTVisitor<UnbridgedCastRewriter>{
- MigrationPass &Pass;
- IdentifierInfo *SelfII;
- std::unique_ptr<ParentMap> StmtMap;
- Decl *ParentD;
- Stmt *Body;
- mutable std::unique_ptr<ExprSet> Removables;
-
-public:
- UnbridgedCastRewriter(MigrationPass &pass)
- : Pass(pass), ParentD(nullptr), Body(nullptr) {
- SelfII = &Pass.Ctx.Idents.get("self");
- }
-
- void transformBody(Stmt *body, Decl *ParentD) {
- this->ParentD = ParentD;
- Body = body;
- StmtMap.reset(new ParentMap(body));
- TraverseStmt(body);
- }
-
- bool TraverseBlockDecl(BlockDecl *D) {
- // ParentMap does not enter into a BlockDecl to record its stmts, so use a
- // new UnbridgedCastRewriter to handle the block.
- UnbridgedCastRewriter(Pass).transformBody(D->getBody(), D);
- return true;
- }
-
- bool VisitCastExpr(CastExpr *E) {
- if (E->getCastKind() != CK_CPointerToObjCPointerCast &&
- E->getCastKind() != CK_BitCast &&
- E->getCastKind() != CK_AnyPointerToBlockPointerCast)
- return true;
-
- QualType castType = E->getType();
- Expr *castExpr = E->getSubExpr();
- QualType castExprType = castExpr->getType();
-
- if (castType->isObjCRetainableType() == castExprType->isObjCRetainableType())
- return true;
-
- bool exprRetainable = castExprType->isObjCIndirectLifetimeType();
- bool castRetainable = castType->isObjCIndirectLifetimeType();
- if (exprRetainable == castRetainable) return true;
-
- if (castExpr->isNullPointerConstant(Pass.Ctx,
- Expr::NPC_ValueDependentIsNull))
- return true;
-
- SourceLocation loc = castExpr->getExprLoc();
- if (loc.isValid() && Pass.Ctx.getSourceManager().isInSystemHeader(loc))
- return true;
-
- if (castType->isObjCRetainableType())
- transformNonObjCToObjCCast(E);
- else
- transformObjCToNonObjCCast(E);
-
- return true;
- }
-
-private:
- void transformNonObjCToObjCCast(CastExpr *E) {
- if (!E) return;
-
- // Global vars are assumed that are cast as unretained.
- if (isGlobalVar(E))
- if (E->getSubExpr()->getType()->isPointerType()) {
- castToObjCObject(E, /*retained=*/false);
- return;
- }
-
- // If the cast is directly over the result of a Core Foundation function
- // try to figure out whether it should be cast as retained or unretained.
- Expr *inner = E->IgnoreParenCasts();
- if (CallExpr *callE = dyn_cast<CallExpr>(inner)) {
- if (FunctionDecl *FD = callE->getDirectCallee()) {
- if (FD->hasAttr<CFReturnsRetainedAttr>()) {
- castToObjCObject(E, /*retained=*/true);
- return;
- }
- if (FD->hasAttr<CFReturnsNotRetainedAttr>()) {
- castToObjCObject(E, /*retained=*/false);
- return;
- }
- if (FD->isGlobal() &&
- FD->getIdentifier() &&
- ento::cocoa::isRefType(E->getSubExpr()->getType(), "CF",
- FD->getIdentifier()->getName())) {
- StringRef fname = FD->getIdentifier()->getName();
- if (fname.ends_with("Retain") || fname.contains("Create") ||
- fname.contains("Copy")) {
- // Do not migrate to couple of bridge transfer casts which
- // cancel each other out. Leave it unchanged so error gets user
- // attention instead.
- if (FD->getName() == "CFRetain" &&
- FD->getNumParams() == 1 &&
- FD->getParent()->isTranslationUnit() &&
- FD->isExternallyVisible()) {
- Expr *Arg = callE->getArg(0);
- if (const ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(Arg)) {
- const Expr *sub = ICE->getSubExpr();
- QualType T = sub->getType();
- if (T->isObjCObjectPointerType())
- return;
- }
- }
- castToObjCObject(E, /*retained=*/true);
- return;
- }
-
- if (fname.contains("Get")) {
- castToObjCObject(E, /*retained=*/false);
- return;
- }
- }
- }
- }
-
- // If returning an ivar or a member of an ivar from a +0 method, use
- // a __bridge cast.
- Expr *base = inner->IgnoreParenImpCasts();
- while (isa<MemberExpr>(base))
- base = cast<MemberExpr>(base)->getBase()->IgnoreParenImpCasts();
- if (isa<ObjCIvarRefExpr>(base) &&
- isa<ReturnStmt>(StmtMap->getParentIgnoreParenCasts(E))) {
- if (ObjCMethodDecl *method = dyn_cast_or_null<ObjCMethodDecl>(ParentD)) {
- if (!method->hasAttr<NSReturnsRetainedAttr>()) {
- castToObjCObject(E, /*retained=*/false);
- return;
- }
- }
- }
- }
-
- void castToObjCObject(CastExpr *E, bool retained) {
- rewriteToBridgedCast(E, retained ? OBC_BridgeTransfer : OBC_Bridge);
- }
-
- void rewriteToBridgedCast(CastExpr *E, ObjCBridgeCastKind Kind) {
- Transaction Trans(Pass.TA);
- rewriteToBridgedCast(E, Kind, Trans);
- }
-
- void rewriteToBridgedCast(CastExpr *E, ObjCBridgeCastKind Kind,
- Transaction &Trans) {
- TransformActions &TA = Pass.TA;
-
- // We will remove the compiler diagnostic.
- if (!TA.hasDiagnostic(diag::err_arc_mismatched_cast,
- diag::err_arc_cast_requires_bridge,
- E->getBeginLoc())) {
- Trans.abort();
- return;
- }
-
- StringRef bridge;
- switch(Kind) {
- case OBC_Bridge:
- bridge = "__bridge "; break;
- case OBC_BridgeTransfer:
- bridge = "__bridge_transfer "; break;
- case OBC_BridgeRetained:
- bridge = "__bridge_retained "; break;
- }
-
- TA.clearDiagnostic(diag::err_arc_mismatched_cast,
- diag::err_arc_cast_requires_bridge, E->getBeginLoc());
- if (Kind == OBC_Bridge || !Pass.CFBridgingFunctionsDefined()) {
- if (CStyleCastExpr *CCE = dyn_cast<CStyleCastExpr>(E)) {
- TA.insertAfterToken(CCE->getLParenLoc(), bridge);
- } else {
- SourceLocation insertLoc = E->getSubExpr()->getBeginLoc();
- SmallString<128> newCast;
- newCast += '(';
- newCast += bridge;
- newCast += E->getType().getAsString(Pass.Ctx.getPrintingPolicy());
- newCast += ')';
-
- if (isa<ParenExpr>(E->getSubExpr())) {
- TA.insert(insertLoc, newCast.str());
- } else {
- newCast += '(';
- TA.insert(insertLoc, newCast.str());
- TA.insertAfterToken(E->getEndLoc(), ")");
- }
- }
- } else {
- assert(Kind == OBC_BridgeTransfer || Kind == OBC_BridgeRetained);
- SmallString<32> BridgeCall;
-
- Expr *WrapE = E->getSubExpr();
- SourceLocation InsertLoc = WrapE->getBeginLoc();
-
- SourceManager &SM = Pass.Ctx.getSourceManager();
- char PrevChar = *SM.getCharacterData(InsertLoc.getLocWithOffset(-1));
- if (Lexer::isAsciiIdentifierContinueChar(PrevChar,
- Pass.Ctx.getLangOpts()))
- BridgeCall += ' ';
-
- if (Kind == OBC_BridgeTransfer)
- BridgeCall += "CFBridgingRelease";
- else
- BridgeCall += "CFBridgingRetain";
-
- if (isa<ParenExpr>(WrapE)) {
- TA.insert(InsertLoc, BridgeCall);
- } else {
- BridgeCall += '(';
- TA.insert(InsertLoc, BridgeCall);
- TA.insertAfterToken(WrapE->getEndLoc(), ")");
- }
- }
- }
-
- void rewriteCastForCFRetain(CastExpr *castE, CallExpr *callE) {
- Transaction Trans(Pass.TA);
- Pass.TA.replace(callE->getSourceRange(), callE->getArg(0)->getSourceRange());
- rewriteToBridgedCast(castE, OBC_BridgeRetained, Trans);
- }
-
- void getBlockMacroRanges(CastExpr *E, SourceRange &Outer, SourceRange &Inner) {
- SourceManager &SM = Pass.Ctx.getSourceManager();
- SourceLocation Loc = E->getExprLoc();
- assert(Loc.isMacroID());
- CharSourceRange MacroRange = SM.getImmediateExpansionRange(Loc);
- SourceRange SubRange = E->getSubExpr()->IgnoreParenImpCasts()->getSourceRange();
- SourceLocation InnerBegin = SM.getImmediateMacroCallerLoc(SubRange.getBegin());
- SourceLocation InnerEnd = SM.getImmediateMacroCallerLoc(SubRange.getEnd());
-
- Outer = MacroRange.getAsRange();
- Inner = SourceRange(InnerBegin, InnerEnd);
- }
-
- void rewriteBlockCopyMacro(CastExpr *E) {
- SourceRange OuterRange, InnerRange;
- getBlockMacroRanges(E, OuterRange, InnerRange);
-
- Transaction Trans(Pass.TA);
- Pass.TA.replace(OuterRange, InnerRange);
- Pass.TA.insert(InnerRange.getBegin(), "[");
- Pass.TA.insertAfterToken(InnerRange.getEnd(), " copy]");
- Pass.TA.clearDiagnostic(diag::err_arc_mismatched_cast,
- diag::err_arc_cast_requires_bridge,
- OuterRange);
- }
-
- void removeBlockReleaseMacro(CastExpr *E) {
- SourceRange OuterRange, InnerRange;
- getBlockMacroRanges(E, OuterRange, InnerRange);
-
- Transaction Trans(Pass.TA);
- Pass.TA.clearDiagnostic(diag::err_arc_mismatched_cast,
- diag::err_arc_cast_requires_bridge,
- OuterRange);
- if (!hasSideEffects(E, Pass.Ctx)) {
- if (tryRemoving(cast<Expr>(StmtMap->getParentIgnoreParenCasts(E))))
- return;
- }
- Pass.TA.replace(OuterRange, InnerRange);
- }
-
- bool tryRemoving(Expr *E) const {
- if (!Removables) {
- Removables.reset(new ExprSet);
- collectRemovables(Body, *Removables);
- }
-
- if (Removables->count(E)) {
- Pass.TA.removeStmt(E);
- return true;
- }
-
- return false;
- }
-
- void transformObjCToNonObjCCast(CastExpr *E) {
- SourceLocation CastLoc = E->getExprLoc();
- if (CastLoc.isMacroID()) {
- StringRef MacroName = Lexer::getImmediateMacroName(CastLoc,
- Pass.Ctx.getSourceManager(),
- Pass.Ctx.getLangOpts());
- if (MacroName == "Block_copy") {
- rewriteBlockCopyMacro(E);
- return;
- }
- if (MacroName == "Block_release") {
- removeBlockReleaseMacro(E);
- return;
- }
- }
-
- if (isSelf(E->getSubExpr()))
- return rewriteToBridgedCast(E, OBC_Bridge);
-
- CallExpr *callE;
- if (isPassedToCFRetain(E, callE))
- return rewriteCastForCFRetain(E, callE);
-
- ObjCMethodFamily family = getFamilyOfMessage(E->getSubExpr());
- if (family == OMF_retain)
- return rewriteToBridgedCast(E, OBC_BridgeRetained);
-
- if (family == OMF_autorelease || family == OMF_release) {
- std::string err = "it is not safe to cast to '";
- err += E->getType().getAsString(Pass.Ctx.getPrintingPolicy());
- err += "' the result of '";
- err += family == OMF_autorelease ? "autorelease" : "release";
- err += "' message; a __bridge cast may result in a pointer to a "
- "destroyed object and a __bridge_retained may leak the object";
- Pass.TA.reportError(err, E->getBeginLoc(),
- E->getSubExpr()->getSourceRange());
- Stmt *parent = E;
- do {
- parent = StmtMap->getParentIgnoreParenImpCasts(parent);
- } while (isa_and_nonnull<FullExpr>(parent));
-
- if (ReturnStmt *retS = dyn_cast_or_null<ReturnStmt>(parent)) {
- std::string note = "remove the cast and change return type of function "
- "to '";
- note += E->getSubExpr()->getType().getAsString(Pass.Ctx.getPrintingPolicy());
- note += "' to have the object automatically autoreleased";
- Pass.TA.reportNote(note, retS->getBeginLoc());
- }
- }
-
- Expr *subExpr = E->getSubExpr();
-
- // Look through pseudo-object expressions.
- if (PseudoObjectExpr *pseudo = dyn_cast<PseudoObjectExpr>(subExpr)) {
- subExpr = pseudo->getResultExpr();
- assert(subExpr && "no result for pseudo-object of non-void type?");
- }
-
- if (ImplicitCastExpr *implCE = dyn_cast<ImplicitCastExpr>(subExpr)) {
- if (implCE->getCastKind() == CK_ARCConsumeObject)
- return rewriteToBridgedCast(E, OBC_BridgeRetained);
- if (implCE->getCastKind() == CK_ARCReclaimReturnedObject)
- return rewriteToBridgedCast(E, OBC_Bridge);
- }
-
- bool isConsumed = false;
- if (isPassedToCParamWithKnownOwnership(E, isConsumed))
- return rewriteToBridgedCast(E, isConsumed ? OBC_BridgeRetained
- : OBC_Bridge);
- }
-
- static ObjCMethodFamily getFamilyOfMessage(Expr *E) {
- E = E->IgnoreParenCasts();
- if (ObjCMessageExpr *ME = dyn_cast<ObjCMessageExpr>(E))
- return ME->getMethodFamily();
-
- return OMF_None;
- }
-
- bool isPassedToCFRetain(Expr *E, CallExpr *&callE) const {
- if ((callE = dyn_cast_or_null<CallExpr>(
- StmtMap->getParentIgnoreParenImpCasts(E))))
- if (FunctionDecl *
- FD = dyn_cast_or_null<FunctionDecl>(callE->getCalleeDecl()))
- if (FD->getName() == "CFRetain" && FD->getNumParams() == 1 &&
- FD->getParent()->isTranslationUnit() &&
- FD->isExternallyVisible())
- return true;
-
- return false;
- }
-
- bool isPassedToCParamWithKnownOwnership(Expr *E, bool &isConsumed) const {
- if (CallExpr *callE = dyn_cast_or_null<CallExpr>(
- StmtMap->getParentIgnoreParenImpCasts(E)))
- if (FunctionDecl *
- FD = dyn_cast_or_null<FunctionDecl>(callE->getCalleeDecl())) {
- unsigned i = 0;
- for (unsigned e = callE->getNumArgs(); i != e; ++i) {
- Expr *arg = callE->getArg(i);
- if (arg == E || arg->IgnoreParenImpCasts() == E)
- break;
- }
- if (i < callE->getNumArgs() && i < FD->getNumParams()) {
- ParmVarDecl *PD = FD->getParamDecl(i);
- if (PD->hasAttr<CFConsumedAttr>()) {
- isConsumed = true;
- return true;
- }
- }
- }
-
- return false;
- }
-
- bool isSelf(Expr *E) const {
- E = E->IgnoreParenLValueCasts();
- if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E))
- if (ImplicitParamDecl *IPD = dyn_cast<ImplicitParamDecl>(DRE->getDecl()))
- if (IPD->getIdentifier() == SelfII)
- return true;
-
- return false;
- }
-};
-
-} // end anonymous namespace
-
-void trans::rewriteUnbridgedCasts(MigrationPass &pass) {
- BodyTransform<UnbridgedCastRewriter> trans(pass);
- trans.TraverseDecl(pass.Ctx.getTranslationUnitDecl());
-}
diff --git a/clang/lib/ARCMigrate/TransUnusedInitDelegate.cpp b/clang/lib/ARCMigrate/TransUnusedInitDelegate.cpp
deleted file mode 100644
index bac8dfac9b415f..00000000000000
--- a/clang/lib/ARCMigrate/TransUnusedInitDelegate.cpp
+++ /dev/null
@@ -1,77 +0,0 @@
-//===--- TransUnusedInitDelegate.cpp - Transformations to ARC mode --------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-// Transformations:
-//===----------------------------------------------------------------------===//
-//
-// rewriteUnusedInitDelegate:
-//
-// Rewrites an unused result of calling a delegate initialization, to assigning
-// the result to self.
-// e.g
-// [self init];
-// ---->
-// self = [self init];
-//
-//===----------------------------------------------------------------------===//
-
-#include "Transforms.h"
-#include "Internals.h"
-#include "clang/AST/ASTContext.h"
-#include "clang/Sema/SemaDiagnostic.h"
-
-using namespace clang;
-using namespace arcmt;
-using namespace trans;
-
-namespace {
-
-class UnusedInitRewriter : public RecursiveASTVisitor<UnusedInitRewriter> {
- Stmt *Body;
- MigrationPass &Pass;
-
- ExprSet Removables;
-
-public:
- UnusedInitRewriter(MigrationPass &pass)
- : Body(nullptr), Pass(pass) { }
-
- void transformBody(Stmt *body, Decl *ParentD) {
- Body = body;
- collectRemovables(body, Removables);
- TraverseStmt(body);
- }
-
- bool VisitObjCMessageExpr(ObjCMessageExpr *ME) {
- if (ME->isDelegateInitCall() &&
- isRemovable(ME) &&
- Pass.TA.hasDiagnostic(diag::err_arc_unused_init_message,
- ME->getExprLoc())) {
- Transaction Trans(Pass.TA);
- Pass.TA.clearDiagnostic(diag::err_arc_unused_init_message,
- ME->getExprLoc());
- SourceRange ExprRange = ME->getSourceRange();
- Pass.TA.insert(ExprRange.getBegin(), "if (!(self = ");
- std::string retStr = ")) return ";
- retStr += getNilString(Pass);
- Pass.TA.insertAfterToken(ExprRange.getEnd(), retStr);
- }
- return true;
- }
-
-private:
- bool isRemovable(Expr *E) const {
- return Removables.count(E);
- }
-};
-
-} // anonymous namespace
-
-void trans::rewriteUnusedInitDelegate(MigrationPass &pass) {
- BodyTransform<UnusedInitRewriter> trans(pass);
- trans.TraverseDecl(pass.Ctx.getTranslationUnitDecl());
-}
diff --git a/clang/lib/ARCMigrate/TransZeroOutPropsInDealloc.cpp b/clang/lib/ARCMigrate/TransZeroOutPropsInDealloc.cpp
deleted file mode 100644
index 81e67628fb1f46..00000000000000
--- a/clang/lib/ARCMigrate/TransZeroOutPropsInDealloc.cpp
+++ /dev/null
@@ -1,224 +0,0 @@
-//===--- TransZeroOutPropsInDealloc.cpp - Transformations to ARC mode -----===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-//
-// removeZeroOutPropsInDealloc:
-//
-// Removes zero'ing out "strong" @synthesized properties in a -dealloc method.
-//
-//===----------------------------------------------------------------------===//
-
-#include "Transforms.h"
-#include "Internals.h"
-#include "clang/AST/ASTContext.h"
-
-using namespace clang;
-using namespace arcmt;
-using namespace trans;
-
-namespace {
-
-class ZeroOutInDeallocRemover :
- public RecursiveASTVisitor<ZeroOutInDeallocRemover> {
- typedef RecursiveASTVisitor<ZeroOutInDeallocRemover> base;
-
- MigrationPass &Pass;
-
- llvm::DenseMap<ObjCPropertyDecl*, ObjCPropertyImplDecl*> SynthesizedProperties;
- ImplicitParamDecl *SelfD;
- ExprSet Removables;
- Selector FinalizeSel;
-
-public:
- ZeroOutInDeallocRemover(MigrationPass &pass) : Pass(pass), SelfD(nullptr) {
- FinalizeSel =
- Pass.Ctx.Selectors.getNullarySelector(&Pass.Ctx.Idents.get("finalize"));
- }
-
- bool VisitObjCMessageExpr(ObjCMessageExpr *ME) {
- ASTContext &Ctx = Pass.Ctx;
- TransformActions &TA = Pass.TA;
-
- if (ME->getReceiverKind() != ObjCMessageExpr::Instance)
- return true;
- Expr *receiver = ME->getInstanceReceiver();
- if (!receiver)
- return true;
-
- DeclRefExpr *refE = dyn_cast<DeclRefExpr>(receiver->IgnoreParenCasts());
- if (!refE || refE->getDecl() != SelfD)
- return true;
-
- bool BackedBySynthesizeSetter = false;
- for (llvm::DenseMap<ObjCPropertyDecl*, ObjCPropertyImplDecl*>::iterator
- P = SynthesizedProperties.begin(),
- E = SynthesizedProperties.end(); P != E; ++P) {
- ObjCPropertyDecl *PropDecl = P->first;
- if (PropDecl->getSetterName() == ME->getSelector()) {
- BackedBySynthesizeSetter = true;
- break;
- }
- }
- if (!BackedBySynthesizeSetter)
- return true;
-
- // Remove the setter message if RHS is null
- Transaction Trans(TA);
- Expr *RHS = ME->getArg(0);
- bool RHSIsNull =
- RHS->isNullPointerConstant(Ctx,
- Expr::NPC_ValueDependentIsNull);
- if (RHSIsNull && isRemovable(ME))
- TA.removeStmt(ME);
-
- return true;
- }
-
- bool VisitPseudoObjectExpr(PseudoObjectExpr *POE) {
- if (isZeroingPropIvar(POE) && isRemovable(POE)) {
- Transaction Trans(Pass.TA);
- Pass.TA.removeStmt(POE);
- }
-
- return true;
- }
-
- bool VisitBinaryOperator(BinaryOperator *BOE) {
- if (isZeroingPropIvar(BOE) && isRemovable(BOE)) {
- Transaction Trans(Pass.TA);
- Pass.TA.removeStmt(BOE);
- }
-
- return true;
- }
-
- bool TraverseObjCMethodDecl(ObjCMethodDecl *D) {
- if (D->getMethodFamily() != OMF_dealloc &&
- !(D->isInstanceMethod() && D->getSelector() == FinalizeSel))
- return true;
- if (!D->hasBody())
- return true;
-
- ObjCImplDecl *IMD = dyn_cast<ObjCImplDecl>(D->getDeclContext());
- if (!IMD)
- return true;
-
- SelfD = D->getSelfDecl();
- collectRemovables(D->getBody(), Removables);
-
- // For a 'dealloc' method use, find all property implementations in
- // this class implementation.
- for (auto *PID : IMD->property_impls()) {
- if (PID->getPropertyImplementation() ==
- ObjCPropertyImplDecl::Synthesize) {
- ObjCPropertyDecl *PD = PID->getPropertyDecl();
- ObjCMethodDecl *setterM = PD->getSetterMethodDecl();
- if (!(setterM && setterM->isDefined())) {
- ObjCPropertyAttribute::Kind AttrKind = PD->getPropertyAttributes();
- if (AttrKind & (ObjCPropertyAttribute::kind_retain |
- ObjCPropertyAttribute::kind_copy |
- ObjCPropertyAttribute::kind_strong))
- SynthesizedProperties[PD] = PID;
- }
- }
- }
-
- // Now, remove all zeroing of ivars etc.
- base::TraverseObjCMethodDecl(D);
-
- // clear out for next method.
- SynthesizedProperties.clear();
- SelfD = nullptr;
- Removables.clear();
- return true;
- }
-
- bool TraverseFunctionDecl(FunctionDecl *D) { return true; }
- bool TraverseBlockDecl(BlockDecl *block) { return true; }
- bool TraverseBlockExpr(BlockExpr *block) { return true; }
-
-private:
- bool isRemovable(Expr *E) const {
- return Removables.count(E);
- }
-
- bool isZeroingPropIvar(Expr *E) {
- E = E->IgnoreParens();
- if (BinaryOperator *BO = dyn_cast<BinaryOperator>(E))
- return isZeroingPropIvar(BO);
- if (PseudoObjectExpr *PO = dyn_cast<PseudoObjectExpr>(E))
- return isZeroingPropIvar(PO);
- return false;
- }
-
- bool isZeroingPropIvar(BinaryOperator *BOE) {
- if (BOE->getOpcode() == BO_Comma)
- return isZeroingPropIvar(BOE->getLHS()) &&
- isZeroingPropIvar(BOE->getRHS());
-
- if (BOE->getOpcode() != BO_Assign)
- return false;
-
- Expr *LHS = BOE->getLHS();
- if (ObjCIvarRefExpr *IV = dyn_cast<ObjCIvarRefExpr>(LHS)) {
- ObjCIvarDecl *IVDecl = IV->getDecl();
- if (!IVDecl->getType()->isObjCObjectPointerType())
- return false;
- bool IvarBacksPropertySynthesis = false;
- for (llvm::DenseMap<ObjCPropertyDecl*, ObjCPropertyImplDecl*>::iterator
- P = SynthesizedProperties.begin(),
- E = SynthesizedProperties.end(); P != E; ++P) {
- ObjCPropertyImplDecl *PropImpDecl = P->second;
- if (PropImpDecl && PropImpDecl->getPropertyIvarDecl() == IVDecl) {
- IvarBacksPropertySynthesis = true;
- break;
- }
- }
- if (!IvarBacksPropertySynthesis)
- return false;
- }
- else
- return false;
-
- return isZero(BOE->getRHS());
- }
-
- bool isZeroingPropIvar(PseudoObjectExpr *PO) {
- BinaryOperator *BO = dyn_cast<BinaryOperator>(PO->getSyntacticForm());
- if (!BO) return false;
- if (BO->getOpcode() != BO_Assign) return false;
-
- ObjCPropertyRefExpr *PropRefExp =
- dyn_cast<ObjCPropertyRefExpr>(BO->getLHS()->IgnoreParens());
- if (!PropRefExp) return false;
-
- // TODO: Using implicit property decl.
- if (PropRefExp->isImplicitProperty())
- return false;
-
- if (ObjCPropertyDecl *PDecl = PropRefExp->getExplicitProperty()) {
- if (!SynthesizedProperties.count(PDecl))
- return false;
- }
-
- return isZero(cast<OpaqueValueExpr>(BO->getRHS())->getSourceExpr());
- }
-
- bool isZero(Expr *E) {
- if (E->isNullPointerConstant(Pass.Ctx, Expr::NPC_ValueDependentIsNull))
- return true;
-
- return isZeroingPropIvar(E);
- }
-};
-
-} // anonymous namespace
-
-void trans::removeZeroOutPropsInDeallocFinalize(MigrationPass &pass) {
- ZeroOutInDeallocRemover trans(pass);
- trans.TraverseDecl(pass.Ctx.getTranslationUnitDecl());
-}
diff --git a/clang/lib/ARCMigrate/TransformActions.cpp b/clang/lib/ARCMigrate/TransformActions.cpp
deleted file mode 100644
index 6bc6fed1a90320..00000000000000
--- a/clang/lib/ARCMigrate/TransformActions.cpp
+++ /dev/null
@@ -1,700 +0,0 @@
-//===-- TransformActions.cpp - Migration to ARC mode ----------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#include "Internals.h"
-#include "clang/AST/ASTContext.h"
-#include "clang/AST/Expr.h"
-#include "clang/Basic/SourceManager.h"
-#include "clang/Lex/Preprocessor.h"
-#include "llvm/ADT/DenseSet.h"
-#include <map>
-using namespace clang;
-using namespace arcmt;
-
-namespace {
-
-/// Collects transformations and merges them before applying them with
-/// with applyRewrites(). E.g. if the same source range
-/// is requested to be removed twice, only one rewriter remove will be invoked.
-/// Rewrites happen in "transactions"; if one rewrite in the transaction cannot
-/// be done (e.g. it resides in a macro) all rewrites in the transaction are
-/// aborted.
-/// FIXME: "Transactional" rewrites support should be baked in the Rewriter.
-class TransformActionsImpl {
- CapturedDiagList &CapturedDiags;
- ASTContext &Ctx;
- Preprocessor &PP;
-
- bool IsInTransaction;
-
- enum ActionKind {
- Act_Insert, Act_InsertAfterToken,
- Act_Remove, Act_RemoveStmt,
- Act_Replace, Act_ReplaceText,
- Act_IncreaseIndentation,
- Act_ClearDiagnostic
- };
-
- struct ActionData {
- ActionKind Kind;
- SourceLocation Loc;
- SourceRange R1, R2;
- StringRef Text1, Text2;
- Stmt *S;
- SmallVector<unsigned, 2> DiagIDs;
- };
-
- std::vector<ActionData> CachedActions;
-
- enum RangeComparison {
- Range_Before,
- Range_After,
- Range_Contains,
- Range_Contained,
- Range_ExtendsBegin,
- Range_ExtendsEnd
- };
-
- /// A range to remove. It is a character range.
- struct CharRange {
- FullSourceLoc Begin, End;
-
- CharRange(CharSourceRange range, SourceManager &srcMgr, Preprocessor &PP) {
- SourceLocation beginLoc = range.getBegin(), endLoc = range.getEnd();
- assert(beginLoc.isValid() && endLoc.isValid());
- if (range.isTokenRange()) {
- Begin = FullSourceLoc(srcMgr.getExpansionLoc(beginLoc), srcMgr);
- End = FullSourceLoc(getLocForEndOfToken(endLoc, srcMgr, PP), srcMgr);
- } else {
- Begin = FullSourceLoc(srcMgr.getExpansionLoc(beginLoc), srcMgr);
- End = FullSourceLoc(srcMgr.getExpansionLoc(endLoc), srcMgr);
- }
- assert(Begin.isValid() && End.isValid());
- }
-
- RangeComparison compareWith(const CharRange &RHS) const {
- if (End.isBeforeInTranslationUnitThan(RHS.Begin))
- return Range_Before;
- if (RHS.End.isBeforeInTranslationUnitThan(Begin))
- return Range_After;
- if (!Begin.isBeforeInTranslationUnitThan(RHS.Begin) &&
- !RHS.End.isBeforeInTranslationUnitThan(End))
- return Range_Contained;
- if (Begin.isBeforeInTranslationUnitThan(RHS.Begin) &&
- RHS.End.isBeforeInTranslationUnitThan(End))
- return Range_Contains;
- if (Begin.isBeforeInTranslationUnitThan(RHS.Begin))
- return Range_ExtendsBegin;
- else
- return Range_ExtendsEnd;
- }
-
- static RangeComparison compare(SourceRange LHS, SourceRange RHS,
- SourceManager &SrcMgr, Preprocessor &PP) {
- return CharRange(CharSourceRange::getTokenRange(LHS), SrcMgr, PP)
- .compareWith(CharRange(CharSourceRange::getTokenRange(RHS),
- SrcMgr, PP));
- }
- };
-
- typedef SmallVector<StringRef, 2> TextsVec;
- typedef std::map<FullSourceLoc, TextsVec, FullSourceLoc::BeforeThanCompare>
- InsertsMap;
- InsertsMap Inserts;
- /// A list of ranges to remove. They are always sorted and they never
- /// intersect with each other.
- std::list<CharRange> Removals;
-
- llvm::DenseSet<Stmt *> StmtRemovals;
-
- std::vector<std::pair<CharRange, SourceLocation> > IndentationRanges;
-
- /// Keeps text passed to transformation methods.
- llvm::StringMap<bool> UniqueText;
-
-public:
- TransformActionsImpl(CapturedDiagList &capturedDiags,
- ASTContext &ctx, Preprocessor &PP)
- : CapturedDiags(capturedDiags), Ctx(ctx), PP(PP), IsInTransaction(false) { }
-
- ASTContext &getASTContext() { return Ctx; }
-
- void startTransaction();
- bool commitTransaction();
- void abortTransaction();
-
- bool isInTransaction() const { return IsInTransaction; }
-
- void insert(SourceLocation loc, StringRef text);
- void insertAfterToken(SourceLocation loc, StringRef text);
- void remove(SourceRange range);
- void removeStmt(Stmt *S);
- void replace(SourceRange range, StringRef text);
- void replace(SourceRange range, SourceRange replacementRange);
- void replaceStmt(Stmt *S, StringRef text);
- void replaceText(SourceLocation loc, StringRef text,
- StringRef replacementText);
- void increaseIndentation(SourceRange range,
- SourceLocation parentIndent);
-
- bool clearDiagnostic(ArrayRef<unsigned> IDs, SourceRange range);
-
- void applyRewrites(TransformActions::RewriteReceiver &receiver);
-
-private:
- bool canInsert(SourceLocation loc);
- bool canInsertAfterToken(SourceLocation loc);
- bool canRemoveRange(SourceRange range);
- bool canReplaceRange(SourceRange range, SourceRange replacementRange);
- bool canReplaceText(SourceLocation loc, StringRef text);
-
- void commitInsert(SourceLocation loc, StringRef text);
- void commitInsertAfterToken(SourceLocation loc, StringRef text);
- void commitRemove(SourceRange range);
- void commitRemoveStmt(Stmt *S);
- void commitReplace(SourceRange range, SourceRange replacementRange);
- void commitReplaceText(SourceLocation loc, StringRef text,
- StringRef replacementText);
- void commitIncreaseIndentation(SourceRange range,SourceLocation parentIndent);
- void commitClearDiagnostic(ArrayRef<unsigned> IDs, SourceRange range);
-
- void addRemoval(CharSourceRange range);
- void addInsertion(SourceLocation loc, StringRef text);
-
- /// Stores text passed to the transformation methods to keep the string
- /// "alive". Since the vast majority of text will be the same, we also unique
- /// the strings using a StringMap.
- StringRef getUniqueText(StringRef text);
-
- /// Computes the source location just past the end of the token at
- /// the given source location. If the location points at a macro, the whole
- /// macro expansion is skipped.
- static SourceLocation getLocForEndOfToken(SourceLocation loc,
- SourceManager &SM,Preprocessor &PP);
-};
-
-} // anonymous namespace
-
-void TransformActionsImpl::startTransaction() {
- assert(!IsInTransaction &&
- "Cannot start a transaction in the middle of another one");
- IsInTransaction = true;
-}
-
-bool TransformActionsImpl::commitTransaction() {
- assert(IsInTransaction && "No transaction started");
-
- if (CachedActions.empty()) {
- IsInTransaction = false;
- return false;
- }
-
- // Verify that all actions are possible otherwise abort the whole transaction.
- bool AllActionsPossible = true;
- for (unsigned i = 0, e = CachedActions.size(); i != e; ++i) {
- ActionData &act = CachedActions[i];
- switch (act.Kind) {
- case Act_Insert:
- if (!canInsert(act.Loc))
- AllActionsPossible = false;
- break;
- case Act_InsertAfterToken:
- if (!canInsertAfterToken(act.Loc))
- AllActionsPossible = false;
- break;
- case Act_Remove:
- if (!canRemoveRange(act.R1))
- AllActionsPossible = false;
- break;
- case Act_RemoveStmt:
- assert(act.S);
- if (!canRemoveRange(act.S->getSourceRange()))
- AllActionsPossible = false;
- break;
- case Act_Replace:
- if (!canReplaceRange(act.R1, act.R2))
- AllActionsPossible = false;
- break;
- case Act_ReplaceText:
- if (!canReplaceText(act.Loc, act.Text1))
- AllActionsPossible = false;
- break;
- case Act_IncreaseIndentation:
- // This is not important, we don't care if it will fail.
- break;
- case Act_ClearDiagnostic:
- // We are just checking source rewrites.
- break;
- }
- if (!AllActionsPossible)
- break;
- }
-
- if (!AllActionsPossible) {
- abortTransaction();
- return true;
- }
-
- for (unsigned i = 0, e = CachedActions.size(); i != e; ++i) {
- ActionData &act = CachedActions[i];
- switch (act.Kind) {
- case Act_Insert:
- commitInsert(act.Loc, act.Text1);
- break;
- case Act_InsertAfterToken:
- commitInsertAfterToken(act.Loc, act.Text1);
- break;
- case Act_Remove:
- commitRemove(act.R1);
- break;
- case Act_RemoveStmt:
- commitRemoveStmt(act.S);
- break;
- case Act_Replace:
- commitReplace(act.R1, act.R2);
- break;
- case Act_ReplaceText:
- commitReplaceText(act.Loc, act.Text1, act.Text2);
- break;
- case Act_IncreaseIndentation:
- commitIncreaseIndentation(act.R1, act.Loc);
- break;
- case Act_ClearDiagnostic:
- commitClearDiagnostic(act.DiagIDs, act.R1);
- break;
- }
- }
-
- CachedActions.clear();
- IsInTransaction = false;
- return false;
-}
-
-void TransformActionsImpl::abortTransaction() {
- assert(IsInTransaction && "No transaction started");
- CachedActions.clear();
- IsInTransaction = false;
-}
-
-void TransformActionsImpl::insert(SourceLocation loc, StringRef text) {
- assert(IsInTransaction && "Actions only allowed during a transaction");
- text = getUniqueText(text);
- ActionData data;
- data.Kind = Act_Insert;
- data.Loc = loc;
- data.Text1 = text;
- CachedActions.push_back(data);
-}
-
-void TransformActionsImpl::insertAfterToken(SourceLocation loc, StringRef text) {
- assert(IsInTransaction && "Actions only allowed during a transaction");
- text = getUniqueText(text);
- ActionData data;
- data.Kind = Act_InsertAfterToken;
- data.Loc = loc;
- data.Text1 = text;
- CachedActions.push_back(data);
-}
-
-void TransformActionsImpl::remove(SourceRange range) {
- assert(IsInTransaction && "Actions only allowed during a transaction");
- ActionData data;
- data.Kind = Act_Remove;
- data.R1 = range;
- CachedActions.push_back(data);
-}
-
-void TransformActionsImpl::removeStmt(Stmt *S) {
- assert(IsInTransaction && "Actions only allowed during a transaction");
- ActionData data;
- data.Kind = Act_RemoveStmt;
- if (auto *E = dyn_cast<Expr>(S))
- S = E->IgnoreImplicit(); // important for uniquing
- data.S = S;
- CachedActions.push_back(data);
-}
-
-void TransformActionsImpl::replace(SourceRange range, StringRef text) {
- assert(IsInTransaction && "Actions only allowed during a transaction");
- text = getUniqueText(text);
- remove(range);
- insert(range.getBegin(), text);
-}
-
-void TransformActionsImpl::replace(SourceRange range,
- SourceRange replacementRange) {
- assert(IsInTransaction && "Actions only allowed during a transaction");
- ActionData data;
- data.Kind = Act_Replace;
- data.R1 = range;
- data.R2 = replacementRange;
- CachedActions.push_back(data);
-}
-
-void TransformActionsImpl::replaceText(SourceLocation loc, StringRef text,
- StringRef replacementText) {
- text = getUniqueText(text);
- replacementText = getUniqueText(replacementText);
- ActionData data;
- data.Kind = Act_ReplaceText;
- data.Loc = loc;
- data.Text1 = text;
- data.Text2 = replacementText;
- CachedActions.push_back(data);
-}
-
-void TransformActionsImpl::replaceStmt(Stmt *S, StringRef text) {
- assert(IsInTransaction && "Actions only allowed during a transaction");
- text = getUniqueText(text);
- insert(S->getBeginLoc(), text);
- removeStmt(S);
-}
-
-void TransformActionsImpl::increaseIndentation(SourceRange range,
- SourceLocation parentIndent) {
- if (range.isInvalid()) return;
- assert(IsInTransaction && "Actions only allowed during a transaction");
- ActionData data;
- data.Kind = Act_IncreaseIndentation;
- data.R1 = range;
- data.Loc = parentIndent;
- CachedActions.push_back(data);
-}
-
-bool TransformActionsImpl::clearDiagnostic(ArrayRef<unsigned> IDs,
- SourceRange range) {
- assert(IsInTransaction && "Actions only allowed during a transaction");
- if (!CapturedDiags.hasDiagnostic(IDs, range))
- return false;
-
- ActionData data;
- data.Kind = Act_ClearDiagnostic;
- data.R1 = range;
- data.DiagIDs.append(IDs.begin(), IDs.end());
- CachedActions.push_back(data);
- return true;
-}
-
-bool TransformActionsImpl::canInsert(SourceLocation loc) {
- if (loc.isInvalid())
- return false;
-
- SourceManager &SM = Ctx.getSourceManager();
- if (SM.isInSystemHeader(SM.getExpansionLoc(loc)))
- return false;
-
- if (loc.isFileID())
- return true;
- return PP.isAtStartOfMacroExpansion(loc);
-}
-
-bool TransformActionsImpl::canInsertAfterToken(SourceLocation loc) {
- if (loc.isInvalid())
- return false;
-
- SourceManager &SM = Ctx.getSourceManager();
- if (SM.isInSystemHeader(SM.getExpansionLoc(loc)))
- return false;
-
- if (loc.isFileID())
- return true;
- return PP.isAtEndOfMacroExpansion(loc);
-}
-
-bool TransformActionsImpl::canRemoveRange(SourceRange range) {
- return canInsert(range.getBegin()) && canInsertAfterToken(range.getEnd());
-}
-
-bool TransformActionsImpl::canReplaceRange(SourceRange range,
- SourceRange replacementRange) {
- return canRemoveRange(range) && canRemoveRange(replacementRange);
-}
-
-bool TransformActionsImpl::canReplaceText(SourceLocation loc, StringRef text) {
- if (!canInsert(loc))
- return false;
-
- SourceManager &SM = Ctx.getSourceManager();
- loc = SM.getExpansionLoc(loc);
-
- // Break down the source location.
- std::pair<FileID, unsigned> locInfo = SM.getDecomposedLoc(loc);
-
- // Try to load the file buffer.
- bool invalidTemp = false;
- StringRef file = SM.getBufferData(locInfo.first, &invalidTemp);
- if (invalidTemp)
- return false;
-
- return file.substr(locInfo.second).starts_with(text);
-}
-
-void TransformActionsImpl::commitInsert(SourceLocation loc, StringRef text) {
- addInsertion(loc, text);
-}
-
-void TransformActionsImpl::commitInsertAfterToken(SourceLocation loc,
- StringRef text) {
- addInsertion(getLocForEndOfToken(loc, Ctx.getSourceManager(), PP), text);
-}
-
-void TransformActionsImpl::commitRemove(SourceRange range) {
- addRemoval(CharSourceRange::getTokenRange(range));
-}
-
-void TransformActionsImpl::commitRemoveStmt(Stmt *S) {
- assert(S);
- if (StmtRemovals.count(S))
- return; // already removed.
-
- if (Expr *E = dyn_cast<Expr>(S)) {
- commitRemove(E->getSourceRange());
- commitInsert(E->getSourceRange().getBegin(), getARCMTMacroName());
- } else
- commitRemove(S->getSourceRange());
-
- StmtRemovals.insert(S);
-}
-
-void TransformActionsImpl::commitReplace(SourceRange range,
- SourceRange replacementRange) {
- RangeComparison comp = CharRange::compare(replacementRange, range,
- Ctx.getSourceManager(), PP);
- assert(comp == Range_Contained);
- if (comp != Range_Contained)
- return; // Although we asserted, be extra safe for release build.
- if (range.getBegin() != replacementRange.getBegin())
- addRemoval(CharSourceRange::getCharRange(range.getBegin(),
- replacementRange.getBegin()));
- if (replacementRange.getEnd() != range.getEnd())
- addRemoval(CharSourceRange::getTokenRange(
- getLocForEndOfToken(replacementRange.getEnd(),
- Ctx.getSourceManager(), PP),
- range.getEnd()));
-}
-void TransformActionsImpl::commitReplaceText(SourceLocation loc,
- StringRef text,
- StringRef replacementText) {
- SourceManager &SM = Ctx.getSourceManager();
- loc = SM.getExpansionLoc(loc);
- // canReplaceText already checked if loc points at text.
- SourceLocation afterText = loc.getLocWithOffset(text.size());
-
- addRemoval(CharSourceRange::getCharRange(loc, afterText));
- commitInsert(loc, replacementText);
-}
-
-void TransformActionsImpl::commitIncreaseIndentation(SourceRange range,
- SourceLocation parentIndent) {
- SourceManager &SM = Ctx.getSourceManager();
- IndentationRanges.push_back(
- std::make_pair(CharRange(CharSourceRange::getTokenRange(range),
- SM, PP),
- SM.getExpansionLoc(parentIndent)));
-}
-
-void TransformActionsImpl::commitClearDiagnostic(ArrayRef<unsigned> IDs,
- SourceRange range) {
- CapturedDiags.clearDiagnostic(IDs, range);
-}
-
-void TransformActionsImpl::addInsertion(SourceLocation loc, StringRef text) {
- SourceManager &SM = Ctx.getSourceManager();
- loc = SM.getExpansionLoc(loc);
- for (const CharRange &I : llvm::reverse(Removals)) {
- if (!SM.isBeforeInTranslationUnit(loc, I.End))
- break;
- if (I.Begin.isBeforeInTranslationUnitThan(loc))
- return;
- }
-
- Inserts[FullSourceLoc(loc, SM)].push_back(text);
-}
-
-void TransformActionsImpl::addRemoval(CharSourceRange range) {
- CharRange newRange(range, Ctx.getSourceManager(), PP);
- if (newRange.Begin == newRange.End)
- return;
-
- Inserts.erase(Inserts.upper_bound(newRange.Begin),
- Inserts.lower_bound(newRange.End));
-
- std::list<CharRange>::iterator I = Removals.end();
- while (I != Removals.begin()) {
- std::list<CharRange>::iterator RI = I;
- --RI;
- RangeComparison comp = newRange.compareWith(*RI);
- switch (comp) {
- case Range_Before:
- --I;
- break;
- case Range_After:
- Removals.insert(I, newRange);
- return;
- case Range_Contained:
- return;
- case Range_Contains:
- RI->End = newRange.End;
- [[fallthrough]];
- case Range_ExtendsBegin:
- newRange.End = RI->End;
- Removals.erase(RI);
- break;
- case Range_ExtendsEnd:
- RI->End = newRange.End;
- return;
- }
- }
-
- Removals.insert(Removals.begin(), newRange);
-}
-
-void TransformActionsImpl::applyRewrites(
- TransformActions::RewriteReceiver &receiver) {
- for (InsertsMap::iterator I = Inserts.begin(), E = Inserts.end(); I!=E; ++I) {
- SourceLocation loc = I->first;
- for (TextsVec::iterator
- TI = I->second.begin(), TE = I->second.end(); TI != TE; ++TI) {
- receiver.insert(loc, *TI);
- }
- }
-
- for (std::vector<std::pair<CharRange, SourceLocation> >::iterator
- I = IndentationRanges.begin(), E = IndentationRanges.end(); I!=E; ++I) {
- CharSourceRange range = CharSourceRange::getCharRange(I->first.Begin,
- I->first.End);
- receiver.increaseIndentation(range, I->second);
- }
-
- for (std::list<CharRange>::iterator
- I = Removals.begin(), E = Removals.end(); I != E; ++I) {
- CharSourceRange range = CharSourceRange::getCharRange(I->Begin, I->End);
- receiver.remove(range);
- }
-}
-
-/// Stores text passed to the transformation methods to keep the string
-/// "alive". Since the vast majority of text will be the same, we also unique
-/// the strings using a StringMap.
-StringRef TransformActionsImpl::getUniqueText(StringRef text) {
- return UniqueText.insert(std::make_pair(text, false)).first->first();
-}
-
-/// Computes the source location just past the end of the token at
-/// the given source location. If the location points at a macro, the whole
-/// macro expansion is skipped.
-SourceLocation TransformActionsImpl::getLocForEndOfToken(SourceLocation loc,
- SourceManager &SM,
- Preprocessor &PP) {
- if (loc.isMacroID()) {
- CharSourceRange Exp = SM.getExpansionRange(loc);
- if (Exp.isCharRange())
- return Exp.getEnd();
- loc = Exp.getEnd();
- }
- return PP.getLocForEndOfToken(loc);
-}
-
-TransformActions::RewriteReceiver::~RewriteReceiver() { }
-
-TransformActions::TransformActions(DiagnosticsEngine &diag,
- CapturedDiagList &capturedDiags,
- ASTContext &ctx, Preprocessor &PP)
- : Diags(diag), CapturedDiags(capturedDiags) {
- Impl = new TransformActionsImpl(capturedDiags, ctx, PP);
-}
-
-TransformActions::~TransformActions() {
- delete static_cast<TransformActionsImpl*>(Impl);
-}
-
-void TransformActions::startTransaction() {
- static_cast<TransformActionsImpl*>(Impl)->startTransaction();
-}
-
-bool TransformActions::commitTransaction() {
- return static_cast<TransformActionsImpl*>(Impl)->commitTransaction();
-}
-
-void TransformActions::abortTransaction() {
- static_cast<TransformActionsImpl*>(Impl)->abortTransaction();
-}
-
-
-void TransformActions::insert(SourceLocation loc, StringRef text) {
- static_cast<TransformActionsImpl*>(Impl)->insert(loc, text);
-}
-
-void TransformActions::insertAfterToken(SourceLocation loc,
- StringRef text) {
- static_cast<TransformActionsImpl*>(Impl)->insertAfterToken(loc, text);
-}
-
-void TransformActions::remove(SourceRange range) {
- static_cast<TransformActionsImpl*>(Impl)->remove(range);
-}
-
-void TransformActions::removeStmt(Stmt *S) {
- static_cast<TransformActionsImpl*>(Impl)->removeStmt(S);
-}
-
-void TransformActions::replace(SourceRange range, StringRef text) {
- static_cast<TransformActionsImpl*>(Impl)->replace(range, text);
-}
-
-void TransformActions::replace(SourceRange range,
- SourceRange replacementRange) {
- static_cast<TransformActionsImpl*>(Impl)->replace(range, replacementRange);
-}
-
-void TransformActions::replaceStmt(Stmt *S, StringRef text) {
- static_cast<TransformActionsImpl*>(Impl)->replaceStmt(S, text);
-}
-
-void TransformActions::replaceText(SourceLocation loc, StringRef text,
- StringRef replacementText) {
- static_cast<TransformActionsImpl*>(Impl)->replaceText(loc, text,
- replacementText);
-}
-
-void TransformActions::increaseIndentation(SourceRange range,
- SourceLocation parentIndent) {
- static_cast<TransformActionsImpl*>(Impl)->increaseIndentation(range,
- parentIndent);
-}
-
-bool TransformActions::clearDiagnostic(ArrayRef<unsigned> IDs,
- SourceRange range) {
- return static_cast<TransformActionsImpl*>(Impl)->clearDiagnostic(IDs, range);
-}
-
-void TransformActions::applyRewrites(RewriteReceiver &receiver) {
- static_cast<TransformActionsImpl*>(Impl)->applyRewrites(receiver);
-}
-
-DiagnosticBuilder TransformActions::report(SourceLocation loc, unsigned diagId,
- SourceRange range) {
- assert(!static_cast<TransformActionsImpl *>(Impl)->isInTransaction() &&
- "Errors should be emitted out of a transaction");
- return Diags.Report(loc, diagId) << range;
-}
-
-void TransformActions::reportError(StringRef message, SourceLocation loc,
- SourceRange range) {
- report(loc, diag::err_mt_message, range) << message;
-}
-
-void TransformActions::reportWarning(StringRef message, SourceLocation loc,
- SourceRange range) {
- report(loc, diag::warn_mt_message, range) << message;
-}
-
-void TransformActions::reportNote(StringRef message, SourceLocation loc,
- SourceRange range) {
- report(loc, diag::note_mt_message, range) << message;
-}
diff --git a/clang/lib/ARCMigrate/Transforms.cpp b/clang/lib/ARCMigrate/Transforms.cpp
deleted file mode 100644
index fda0e1c932fc0e..00000000000000
--- a/clang/lib/ARCMigrate/Transforms.cpp
+++ /dev/null
@@ -1,594 +0,0 @@
-//===--- Transforms.cpp - Transformations to ARC mode ---------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#include "Transforms.h"
-#include "Internals.h"
-#include "clang/ARCMigrate/ARCMT.h"
-#include "clang/AST/ASTContext.h"
-#include "clang/AST/RecursiveASTVisitor.h"
-#include "clang/Analysis/DomainSpecific/CocoaConventions.h"
-#include "clang/Basic/SourceManager.h"
-#include "clang/Basic/TargetInfo.h"
-#include "clang/Lex/Lexer.h"
-#include "clang/Lex/Preprocessor.h"
-#include "clang/Sema/Sema.h"
-#include "clang/Sema/SemaObjC.h"
-
-using namespace clang;
-using namespace arcmt;
-using namespace trans;
-
-ASTTraverser::~ASTTraverser() { }
-
-bool MigrationPass::CFBridgingFunctionsDefined() {
- if (!EnableCFBridgeFns)
- EnableCFBridgeFns = SemaRef.ObjC().isKnownName("CFBridgingRetain") &&
- SemaRef.ObjC().isKnownName("CFBridgingRelease");
- return *EnableCFBridgeFns;
-}
-
-//===----------------------------------------------------------------------===//
-// Helpers.
-//===----------------------------------------------------------------------===//
-
-bool trans::canApplyWeak(ASTContext &Ctx, QualType type,
- bool AllowOnUnknownClass) {
- if (!Ctx.getLangOpts().ObjCWeakRuntime)
- return false;
-
- QualType T = type;
- if (T.isNull())
- return false;
-
- // iOS is always safe to use 'weak'.
- if (Ctx.getTargetInfo().getTriple().isiOS() ||
- Ctx.getTargetInfo().getTriple().isWatchOS())
- AllowOnUnknownClass = true;
-
- while (const PointerType *ptr = T->getAs<PointerType>())
- T = ptr->getPointeeType();
- if (const ObjCObjectPointerType *ObjT = T->getAs<ObjCObjectPointerType>()) {
- ObjCInterfaceDecl *Class = ObjT->getInterfaceDecl();
- if (!AllowOnUnknownClass && (!Class || Class->getName() == "NSObject"))
- return false; // id/NSObject is not safe for weak.
- if (!AllowOnUnknownClass && !Class->hasDefinition())
- return false; // forward classes are not verifiable, therefore not safe.
- if (Class && Class->isArcWeakrefUnavailable())
- return false;
- }
-
- return true;
-}
-
-bool trans::isPlusOneAssign(const BinaryOperator *E) {
- if (E->getOpcode() != BO_Assign)
- return false;
-
- return isPlusOne(E->getRHS());
-}
-
-bool trans::isPlusOne(const Expr *E) {
- if (!E)
- return false;
- if (const FullExpr *FE = dyn_cast<FullExpr>(E))
- E = FE->getSubExpr();
-
- if (const ObjCMessageExpr *
- ME = dyn_cast<ObjCMessageExpr>(E->IgnoreParenCasts()))
- if (ME->getMethodFamily() == OMF_retain)
- return true;
-
- if (const CallExpr *
- callE = dyn_cast<CallExpr>(E->IgnoreParenCasts())) {
- if (const FunctionDecl *FD = callE->getDirectCallee()) {
- if (FD->hasAttr<CFReturnsRetainedAttr>())
- return true;
-
- if (FD->isGlobal() &&
- FD->getIdentifier() &&
- FD->getParent()->isTranslationUnit() &&
- FD->isExternallyVisible() &&
- ento::cocoa::isRefType(callE->getType(), "CF",
- FD->getIdentifier()->getName())) {
- StringRef fname = FD->getIdentifier()->getName();
- if (fname.ends_with("Retain") || fname.contains("Create") ||
- fname.contains("Copy"))
- return true;
- }
- }
- }
-
- const ImplicitCastExpr *implCE = dyn_cast<ImplicitCastExpr>(E);
- while (implCE && implCE->getCastKind() == CK_BitCast)
- implCE = dyn_cast<ImplicitCastExpr>(implCE->getSubExpr());
-
- return implCE && implCE->getCastKind() == CK_ARCConsumeObject;
-}
-
-/// 'Loc' is the end of a statement range. This returns the location
-/// immediately after the semicolon following the statement.
-/// If no semicolon is found or the location is inside a macro, the returned
-/// source location will be invalid.
-SourceLocation trans::findLocationAfterSemi(SourceLocation loc,
- ASTContext &Ctx, bool IsDecl) {
- SourceLocation SemiLoc = findSemiAfterLocation(loc, Ctx, IsDecl);
- if (SemiLoc.isInvalid())
- return SourceLocation();
- return SemiLoc.getLocWithOffset(1);
-}
-
-/// \arg Loc is the end of a statement range. This returns the location
-/// of the semicolon following the statement.
-/// If no semicolon is found or the location is inside a macro, the returned
-/// source location will be invalid.
-SourceLocation trans::findSemiAfterLocation(SourceLocation loc,
- ASTContext &Ctx,
- bool IsDecl) {
- SourceManager &SM = Ctx.getSourceManager();
- if (loc.isMacroID()) {
- if (!Lexer::isAtEndOfMacroExpansion(loc, SM, Ctx.getLangOpts(), &loc))
- return SourceLocation();
- }
- loc = Lexer::getLocForEndOfToken(loc, /*Offset=*/0, SM, Ctx.getLangOpts());
-
- // Break down the source location.
- std::pair<FileID, unsigned> locInfo = SM.getDecomposedLoc(loc);
-
- // Try to load the file buffer.
- bool invalidTemp = false;
- StringRef file = SM.getBufferData(locInfo.first, &invalidTemp);
- if (invalidTemp)
- return SourceLocation();
-
- const char *tokenBegin = file.data() + locInfo.second;
-
- // Lex from the start of the given location.
- Lexer lexer(SM.getLocForStartOfFile(locInfo.first),
- Ctx.getLangOpts(),
- file.begin(), tokenBegin, file.end());
- Token tok;
- lexer.LexFromRawLexer(tok);
- if (tok.isNot(tok::semi)) {
- if (!IsDecl)
- return SourceLocation();
- // Declaration may be followed with other tokens; such as an __attribute,
- // before ending with a semicolon.
- return findSemiAfterLocation(tok.getLocation(), Ctx, /*IsDecl*/true);
- }
-
- return tok.getLocation();
-}
-
-bool trans::hasSideEffects(Expr *E, ASTContext &Ctx) {
- if (!E || !E->HasSideEffects(Ctx))
- return false;
-
- E = E->IgnoreParenCasts();
- ObjCMessageExpr *ME = dyn_cast<ObjCMessageExpr>(E);
- if (!ME)
- return true;
- switch (ME->getMethodFamily()) {
- case OMF_autorelease:
- case OMF_dealloc:
- case OMF_release:
- case OMF_retain:
- switch (ME->getReceiverKind()) {
- case ObjCMessageExpr::SuperInstance:
- return false;
- case ObjCMessageExpr::Instance:
- return hasSideEffects(ME->getInstanceReceiver(), Ctx);
- default:
- break;
- }
- break;
- default:
- break;
- }
-
- return true;
-}
-
-bool trans::isGlobalVar(Expr *E) {
- E = E->IgnoreParenCasts();
- if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E))
- return DRE->getDecl()->getDeclContext()->isFileContext() &&
- DRE->getDecl()->isExternallyVisible();
- if (ConditionalOperator *condOp = dyn_cast<ConditionalOperator>(E))
- return isGlobalVar(condOp->getTrueExpr()) &&
- isGlobalVar(condOp->getFalseExpr());
-
- return false;
-}
-
-StringRef trans::getNilString(MigrationPass &Pass) {
- return Pass.SemaRef.PP.isMacroDefined("nil") ? "nil" : "0";
-}
-
-namespace {
-
-class ReferenceClear : public RecursiveASTVisitor<ReferenceClear> {
- ExprSet &Refs;
-public:
- ReferenceClear(ExprSet &refs) : Refs(refs) { }
- bool VisitDeclRefExpr(DeclRefExpr *E) { Refs.erase(E); return true; }
-};
-
-class ReferenceCollector : public RecursiveASTVisitor<ReferenceCollector> {
- ValueDecl *Dcl;
- ExprSet &Refs;
-
-public:
- ReferenceCollector(ValueDecl *D, ExprSet &refs)
- : Dcl(D), Refs(refs) { }
-
- bool VisitDeclRefExpr(DeclRefExpr *E) {
- if (E->getDecl() == Dcl)
- Refs.insert(E);
- return true;
- }
-};
-
-class RemovablesCollector : public RecursiveASTVisitor<RemovablesCollector> {
- ExprSet &Removables;
-
-public:
- RemovablesCollector(ExprSet &removables)
- : Removables(removables) { }
-
- bool shouldWalkTypesOfTypeLocs() const { return false; }
-
- bool TraverseStmtExpr(StmtExpr *E) {
- CompoundStmt *S = E->getSubStmt();
- for (CompoundStmt::body_iterator
- I = S->body_begin(), E = S->body_end(); I != E; ++I) {
- if (I != E - 1)
- mark(*I);
- TraverseStmt(*I);
- }
- return true;
- }
-
- bool VisitCompoundStmt(CompoundStmt *S) {
- for (auto *I : S->body())
- mark(I);
- return true;
- }
-
- bool VisitIfStmt(IfStmt *S) {
- mark(S->getThen());
- mark(S->getElse());
- return true;
- }
-
- bool VisitWhileStmt(WhileStmt *S) {
- mark(S->getBody());
- return true;
- }
-
- bool VisitDoStmt(DoStmt *S) {
- mark(S->getBody());
- return true;
- }
-
- bool VisitForStmt(ForStmt *S) {
- mark(S->getInit());
- mark(S->getInc());
- mark(S->getBody());
- return true;
- }
-
-private:
- void mark(Stmt *S) {
- if (!S) return;
-
- while (auto *Label = dyn_cast<LabelStmt>(S))
- S = Label->getSubStmt();
- if (auto *E = dyn_cast<Expr>(S))
- S = E->IgnoreImplicit();
- if (auto *E = dyn_cast<Expr>(S))
- Removables.insert(E);
- }
-};
-
-} // end anonymous namespace
-
-void trans::clearRefsIn(Stmt *S, ExprSet &refs) {
- ReferenceClear(refs).TraverseStmt(S);
-}
-
-void trans::collectRefs(ValueDecl *D, Stmt *S, ExprSet &refs) {
- ReferenceCollector(D, refs).TraverseStmt(S);
-}
-
-void trans::collectRemovables(Stmt *S, ExprSet &exprs) {
- RemovablesCollector(exprs).TraverseStmt(S);
-}
-
-//===----------------------------------------------------------------------===//
-// MigrationContext
-//===----------------------------------------------------------------------===//
-
-namespace {
-
-class ASTTransform : public RecursiveASTVisitor<ASTTransform> {
- MigrationContext &MigrateCtx;
- typedef RecursiveASTVisitor<ASTTransform> base;
-
-public:
- ASTTransform(MigrationContext &MigrateCtx) : MigrateCtx(MigrateCtx) { }
-
- bool shouldWalkTypesOfTypeLocs() const { return false; }
-
- bool TraverseObjCImplementationDecl(ObjCImplementationDecl *D) {
- ObjCImplementationContext ImplCtx(MigrateCtx, D);
- for (MigrationContext::traverser_iterator
- I = MigrateCtx.traversers_begin(),
- E = MigrateCtx.traversers_end(); I != E; ++I)
- (*I)->traverseObjCImplementation(ImplCtx);
-
- return base::TraverseObjCImplementationDecl(D);
- }
-
- bool TraverseStmt(Stmt *rootS) {
- if (!rootS)
- return true;
-
- BodyContext BodyCtx(MigrateCtx, rootS);
- for (MigrationContext::traverser_iterator
- I = MigrateCtx.traversers_begin(),
- E = MigrateCtx.traversers_end(); I != E; ++I)
- (*I)->traverseBody(BodyCtx);
-
- return true;
- }
-};
-
-}
-
-MigrationContext::~MigrationContext() {
- for (traverser_iterator
- I = traversers_begin(), E = traversers_end(); I != E; ++I)
- delete *I;
-}
-
-bool MigrationContext::isGCOwnedNonObjC(QualType T) {
- while (!T.isNull()) {
- if (const AttributedType *AttrT = T->getAs<AttributedType>()) {
- if (AttrT->getAttrKind() == attr::ObjCOwnership)
- return !AttrT->getModifiedType()->isObjCRetainableType();
- }
-
- if (T->isArrayType())
- T = Pass.Ctx.getBaseElementType(T);
- else if (const PointerType *PT = T->getAs<PointerType>())
- T = PT->getPointeeType();
- else if (const ReferenceType *RT = T->getAs<ReferenceType>())
- T = RT->getPointeeType();
- else
- break;
- }
-
- return false;
-}
-
-bool MigrationContext::rewritePropertyAttribute(StringRef fromAttr,
- StringRef toAttr,
- SourceLocation atLoc) {
- if (atLoc.isMacroID())
- return false;
-
- SourceManager &SM = Pass.Ctx.getSourceManager();
-
- // Break down the source location.
- std::pair<FileID, unsigned> locInfo = SM.getDecomposedLoc(atLoc);
-
- // Try to load the file buffer.
- bool invalidTemp = false;
- StringRef file = SM.getBufferData(locInfo.first, &invalidTemp);
- if (invalidTemp)
- return false;
-
- const char *tokenBegin = file.data() + locInfo.second;
-
- // Lex from the start of the given location.
- Lexer lexer(SM.getLocForStartOfFile(locInfo.first),
- Pass.Ctx.getLangOpts(),
- file.begin(), tokenBegin, file.end());
- Token tok;
- lexer.LexFromRawLexer(tok);
- if (tok.isNot(tok::at)) return false;
- lexer.LexFromRawLexer(tok);
- if (tok.isNot(tok::raw_identifier)) return false;
- if (tok.getRawIdentifier() != "property")
- return false;
- lexer.LexFromRawLexer(tok);
- if (tok.isNot(tok::l_paren)) return false;
-
- Token BeforeTok = tok;
- Token AfterTok;
- AfterTok.startToken();
- SourceLocation AttrLoc;
-
- lexer.LexFromRawLexer(tok);
- if (tok.is(tok::r_paren))
- return false;
-
- while (true) {
- if (tok.isNot(tok::raw_identifier)) return false;
- if (tok.getRawIdentifier() == fromAttr) {
- if (!toAttr.empty()) {
- Pass.TA.replaceText(tok.getLocation(), fromAttr, toAttr);
- return true;
- }
- // We want to remove the attribute.
- AttrLoc = tok.getLocation();
- }
-
- do {
- lexer.LexFromRawLexer(tok);
- if (AttrLoc.isValid() && AfterTok.is(tok::unknown))
- AfterTok = tok;
- } while (tok.isNot(tok::comma) && tok.isNot(tok::r_paren));
- if (tok.is(tok::r_paren))
- break;
- if (AttrLoc.isInvalid())
- BeforeTok = tok;
- lexer.LexFromRawLexer(tok);
- }
-
- if (toAttr.empty() && AttrLoc.isValid() && AfterTok.isNot(tok::unknown)) {
- // We want to remove the attribute.
- if (BeforeTok.is(tok::l_paren) && AfterTok.is(tok::r_paren)) {
- Pass.TA.remove(SourceRange(BeforeTok.getLocation(),
- AfterTok.getLocation()));
- } else if (BeforeTok.is(tok::l_paren) && AfterTok.is(tok::comma)) {
- Pass.TA.remove(SourceRange(AttrLoc, AfterTok.getLocation()));
- } else {
- Pass.TA.remove(SourceRange(BeforeTok.getLocation(), AttrLoc));
- }
-
- return true;
- }
-
- return false;
-}
-
-bool MigrationContext::addPropertyAttribute(StringRef attr,
- SourceLocation atLoc) {
- if (atLoc.isMacroID())
- return false;
-
- SourceManager &SM = Pass.Ctx.getSourceManager();
-
- // Break down the source location.
- std::pair<FileID, unsigned> locInfo = SM.getDecomposedLoc(atLoc);
-
- // Try to load the file buffer.
- bool invalidTemp = false;
- StringRef file = SM.getBufferData(locInfo.first, &invalidTemp);
- if (invalidTemp)
- return false;
-
- const char *tokenBegin = file.data() + locInfo.second;
-
- // Lex from the start of the given location.
- Lexer lexer(SM.getLocForStartOfFile(locInfo.first),
- Pass.Ctx.getLangOpts(),
- file.begin(), tokenBegin, file.end());
- Token tok;
- lexer.LexFromRawLexer(tok);
- if (tok.isNot(tok::at)) return false;
- lexer.LexFromRawLexer(tok);
- if (tok.isNot(tok::raw_identifier)) return false;
- if (tok.getRawIdentifier() != "property")
- return false;
- lexer.LexFromRawLexer(tok);
-
- if (tok.isNot(tok::l_paren)) {
- Pass.TA.insert(tok.getLocation(), std::string("(") + attr.str() + ") ");
- return true;
- }
-
- lexer.LexFromRawLexer(tok);
- if (tok.is(tok::r_paren)) {
- Pass.TA.insert(tok.getLocation(), attr);
- return true;
- }
-
- if (tok.isNot(tok::raw_identifier)) return false;
-
- Pass.TA.insert(tok.getLocation(), std::string(attr) + ", ");
- return true;
-}
-
-void MigrationContext::traverse(TranslationUnitDecl *TU) {
- for (traverser_iterator
- I = traversers_begin(), E = traversers_end(); I != E; ++I)
- (*I)->traverseTU(*this);
-
- ASTTransform(*this).TraverseDecl(TU);
-}
-
-static void GCRewriteFinalize(MigrationPass &pass) {
- ASTContext &Ctx = pass.Ctx;
- TransformActions &TA = pass.TA;
- DeclContext *DC = Ctx.getTranslationUnitDecl();
- Selector FinalizeSel =
- Ctx.Selectors.getNullarySelector(&pass.Ctx.Idents.get("finalize"));
-
- typedef DeclContext::specific_decl_iterator<ObjCImplementationDecl>
- impl_iterator;
- for (impl_iterator I = impl_iterator(DC->decls_begin()),
- E = impl_iterator(DC->decls_end()); I != E; ++I) {
- for (const auto *MD : I->instance_methods()) {
- if (!MD->hasBody())
- continue;
-
- if (MD->isInstanceMethod() && MD->getSelector() == FinalizeSel) {
- const ObjCMethodDecl *FinalizeM = MD;
- Transaction Trans(TA);
- TA.insert(FinalizeM->getSourceRange().getBegin(),
- "#if !__has_feature(objc_arc)\n");
- CharSourceRange::getTokenRange(FinalizeM->getSourceRange());
- const SourceManager &SM = pass.Ctx.getSourceManager();
- const LangOptions &LangOpts = pass.Ctx.getLangOpts();
- bool Invalid;
- std::string str = "\n#endif\n";
- str += Lexer::getSourceText(
- CharSourceRange::getTokenRange(FinalizeM->getSourceRange()),
- SM, LangOpts, &Invalid);
- TA.insertAfterToken(FinalizeM->getSourceRange().getEnd(), str);
-
- break;
- }
- }
- }
-}
-
-//===----------------------------------------------------------------------===//
-// getAllTransformations.
-//===----------------------------------------------------------------------===//
-
-static void traverseAST(MigrationPass &pass) {
- MigrationContext MigrateCtx(pass);
-
- if (pass.isGCMigration()) {
- MigrateCtx.addTraverser(new GCCollectableCallsTraverser);
- MigrateCtx.addTraverser(new GCAttrsTraverser());
- }
- MigrateCtx.addTraverser(new PropertyRewriteTraverser());
- MigrateCtx.addTraverser(new BlockObjCVariableTraverser());
- MigrateCtx.addTraverser(new ProtectedScopeTraverser());
-
- MigrateCtx.traverse(pass.Ctx.getTranslationUnitDecl());
-}
-
-static void independentTransforms(MigrationPass &pass) {
- rewriteAutoreleasePool(pass);
- removeRetainReleaseDeallocFinalize(pass);
- rewriteUnusedInitDelegate(pass);
- removeZeroOutPropsInDeallocFinalize(pass);
- makeAssignARCSafe(pass);
- rewriteUnbridgedCasts(pass);
- checkAPIUses(pass);
- traverseAST(pass);
-}
-
-std::vector<TransformFn> arcmt::getAllTransformations(
- LangOptions::GCMode OrigGCMode,
- bool NoFinalizeRemoval) {
- std::vector<TransformFn> transforms;
-
- if (OrigGCMode == LangOptions::GCOnly && NoFinalizeRemoval)
- transforms.push_back(GCRewriteFinalize);
- transforms.push_back(independentTransforms);
- // This depends on previous transformations removing various expressions.
- transforms.push_back(removeEmptyStatementsAndDeallocFinalize);
-
- return transforms;
-}
diff --git a/clang/lib/ARCMigrate/Transforms.h b/clang/lib/ARCMigrate/Transforms.h
deleted file mode 100644
index 37e2d6b2a7e12f..00000000000000
--- a/clang/lib/ARCMigrate/Transforms.h
+++ /dev/null
@@ -1,224 +0,0 @@
-//===-- Transforms.h - Transformations to ARC mode --------------*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_CLANG_LIB_ARCMIGRATE_TRANSFORMS_H
-#define LLVM_CLANG_LIB_ARCMIGRATE_TRANSFORMS_H
-
-#include "clang/AST/ParentMap.h"
-#include "clang/AST/RecursiveASTVisitor.h"
-#include "llvm/ADT/DenseSet.h"
-#include "llvm/Support/SaveAndRestore.h"
-
-namespace clang {
- class Decl;
- class Stmt;
- class BlockDecl;
- class ObjCMethodDecl;
- class FunctionDecl;
-
-namespace arcmt {
- class MigrationPass;
-
-namespace trans {
-
- class MigrationContext;
-
-//===----------------------------------------------------------------------===//
-// Transformations.
-//===----------------------------------------------------------------------===//
-
-void rewriteAutoreleasePool(MigrationPass &pass);
-void rewriteUnbridgedCasts(MigrationPass &pass);
-void makeAssignARCSafe(MigrationPass &pass);
-void removeRetainReleaseDeallocFinalize(MigrationPass &pass);
-void removeZeroOutPropsInDeallocFinalize(MigrationPass &pass);
-void rewriteUnusedInitDelegate(MigrationPass &pass);
-void checkAPIUses(MigrationPass &pass);
-
-void removeEmptyStatementsAndDeallocFinalize(MigrationPass &pass);
-
-class BodyContext {
- MigrationContext &MigrateCtx;
- ParentMap PMap;
- Stmt *TopStmt;
-
-public:
- BodyContext(MigrationContext &MigrateCtx, Stmt *S)
- : MigrateCtx(MigrateCtx), PMap(S), TopStmt(S) {}
-
- MigrationContext &getMigrationContext() { return MigrateCtx; }
- ParentMap &getParentMap() { return PMap; }
- Stmt *getTopStmt() { return TopStmt; }
-};
-
-class ObjCImplementationContext {
- MigrationContext &MigrateCtx;
- ObjCImplementationDecl *ImpD;
-
-public:
- ObjCImplementationContext(MigrationContext &MigrateCtx,
- ObjCImplementationDecl *D)
- : MigrateCtx(MigrateCtx), ImpD(D) {}
-
- MigrationContext &getMigrationContext() { return MigrateCtx; }
- ObjCImplementationDecl *getImplementationDecl() { return ImpD; }
-};
-
-class ASTTraverser {
-public:
- virtual ~ASTTraverser();
- virtual void traverseTU(MigrationContext &MigrateCtx) { }
- virtual void traverseBody(BodyContext &BodyCtx) { }
- virtual void traverseObjCImplementation(ObjCImplementationContext &ImplCtx) {}
-};
-
-class MigrationContext {
- std::vector<ASTTraverser *> Traversers;
-
-public:
- MigrationPass &Pass;
-
- struct GCAttrOccurrence {
- enum AttrKind { Weak, Strong } Kind;
- SourceLocation Loc;
- QualType ModifiedType;
- Decl *Dcl;
- /// true if the attribute is owned, e.g. it is in a body and not just
- /// in an interface.
- bool FullyMigratable;
- };
- std::vector<GCAttrOccurrence> GCAttrs;
- llvm::DenseSet<SourceLocation> AttrSet;
- llvm::DenseSet<SourceLocation> RemovedAttrSet;
-
- /// Set of raw '@' locations for 'assign' properties group that contain
- /// GC __weak.
- llvm::DenseSet<SourceLocation> AtPropsWeak;
-
- explicit MigrationContext(MigrationPass &pass) : Pass(pass) {}
- ~MigrationContext();
-
- typedef std::vector<ASTTraverser *>::iterator traverser_iterator;
- traverser_iterator traversers_begin() { return Traversers.begin(); }
- traverser_iterator traversers_end() { return Traversers.end(); }
-
- void addTraverser(ASTTraverser *traverser) {
- Traversers.push_back(traverser);
- }
-
- bool isGCOwnedNonObjC(QualType T);
- bool removePropertyAttribute(StringRef fromAttr, SourceLocation atLoc) {
- return rewritePropertyAttribute(fromAttr, StringRef(), atLoc);
- }
- bool rewritePropertyAttribute(StringRef fromAttr, StringRef toAttr,
- SourceLocation atLoc);
- bool addPropertyAttribute(StringRef attr, SourceLocation atLoc);
-
- void traverse(TranslationUnitDecl *TU);
-
- void dumpGCAttrs();
-};
-
-class PropertyRewriteTraverser : public ASTTraverser {
-public:
- void traverseObjCImplementation(ObjCImplementationContext &ImplCtx) override;
-};
-
-class BlockObjCVariableTraverser : public ASTTraverser {
-public:
- void traverseBody(BodyContext &BodyCtx) override;
-};
-
-class ProtectedScopeTraverser : public ASTTraverser {
-public:
- void traverseBody(BodyContext &BodyCtx) override;
-};
-
-// GC transformations
-
-class GCAttrsTraverser : public ASTTraverser {
-public:
- void traverseTU(MigrationContext &MigrateCtx) override;
-};
-
-class GCCollectableCallsTraverser : public ASTTraverser {
-public:
- void traverseBody(BodyContext &BodyCtx) override;
-};
-
-//===----------------------------------------------------------------------===//
-// Helpers.
-//===----------------------------------------------------------------------===//
-
-/// Determine whether we can add weak to the given type.
-bool canApplyWeak(ASTContext &Ctx, QualType type,
- bool AllowOnUnknownClass = false);
-
-bool isPlusOneAssign(const BinaryOperator *E);
-bool isPlusOne(const Expr *E);
-
-/// 'Loc' is the end of a statement range. This returns the location
-/// immediately after the semicolon following the statement.
-/// If no semicolon is found or the location is inside a macro, the returned
-/// source location will be invalid.
-SourceLocation findLocationAfterSemi(SourceLocation loc, ASTContext &Ctx,
- bool IsDecl = false);
-
-/// 'Loc' is the end of a statement range. This returns the location
-/// of the semicolon following the statement.
-/// If no semicolon is found or the location is inside a macro, the returned
-/// source location will be invalid.
-SourceLocation findSemiAfterLocation(SourceLocation loc, ASTContext &Ctx,
- bool IsDecl = false);
-
-bool hasSideEffects(Expr *E, ASTContext &Ctx);
-bool isGlobalVar(Expr *E);
-/// Returns "nil" or "0" if 'nil' macro is not actually defined.
-StringRef getNilString(MigrationPass &Pass);
-
-template <typename BODY_TRANS>
-class BodyTransform : public RecursiveASTVisitor<BodyTransform<BODY_TRANS> > {
- MigrationPass &Pass;
- Decl *ParentD;
-
- typedef RecursiveASTVisitor<BodyTransform<BODY_TRANS> > base;
-public:
- BodyTransform(MigrationPass &pass) : Pass(pass), ParentD(nullptr) { }
-
- bool TraverseStmt(Stmt *rootS) {
- if (rootS)
- BODY_TRANS(Pass).transformBody(rootS, ParentD);
- return true;
- }
-
- bool TraverseObjCMethodDecl(ObjCMethodDecl *D) {
- SaveAndRestore<Decl *> SetParent(ParentD, D);
- return base::TraverseObjCMethodDecl(D);
- }
-};
-
-typedef llvm::DenseSet<Expr *> ExprSet;
-
-void clearRefsIn(Stmt *S, ExprSet &refs);
-template <typename iterator>
-void clearRefsIn(iterator begin, iterator end, ExprSet &refs) {
- for (; begin != end; ++begin)
- clearRefsIn(*begin, refs);
-}
-
-void collectRefs(ValueDecl *D, Stmt *S, ExprSet &refs);
-
-void collectRemovables(Stmt *S, ExprSet &exprs);
-
-} // end namespace trans
-
-} // end namespace arcmt
-
-} // end namespace clang
-
-#endif
diff --git a/clang/test/ARCMT/Common.h b/clang/test/ARCMT/Common.h
deleted file mode 100644
index b388ecab741097..00000000000000
--- a/clang/test/ARCMT/Common.h
+++ /dev/null
@@ -1,110 +0,0 @@
-#if __has_feature(objc_arr)
-#define NS_AUTOMATED_REFCOUNT_UNAVAILABLE __attribute__((unavailable("not available in automatic reference counting mode")))
-#else
-#define NS_AUTOMATED_REFCOUNT_UNAVAILABLE
-#endif
-
-#define NS_RETURNS_RETAINED __attribute__((ns_returns_retained))
-#define CF_CONSUMED __attribute__((cf_consumed))
-#define CF_RETURNS_RETAINED __attribute__((cf_returns_retained))
-
-#define NS_INLINE static __inline__ __attribute__((always_inline))
-#define nil ((void*) 0)
-#define NULL ((void*)0)
-
-typedef int BOOL;
-typedef unsigned NSUInteger;
-typedef int int32_t;
-typedef unsigned char uint8_t;
-typedef int32_t UChar32;
-typedef unsigned char UChar;
-
-typedef struct _NSZone NSZone;
-
-typedef const void * CFTypeRef;
-CFTypeRef CFRetain(CFTypeRef cf);
-CFTypeRef CFMakeCollectable(CFTypeRef cf) NS_AUTOMATED_REFCOUNT_UNAVAILABLE;
-
-NS_INLINE NS_RETURNS_RETAINED id NSMakeCollectable(CFTypeRef CF_CONSUMED cf) NS_AUTOMATED_REFCOUNT_UNAVAILABLE;
-
- at protocol NSObject
-- (BOOL)isEqual:(id)object;
-- (NSZone *)zone NS_AUTOMATED_REFCOUNT_UNAVAILABLE;
-- (id)retain NS_AUTOMATED_REFCOUNT_UNAVAILABLE;
-- (NSUInteger)retainCount NS_AUTOMATED_REFCOUNT_UNAVAILABLE;
-- (oneway void)release NS_AUTOMATED_REFCOUNT_UNAVAILABLE;
-- (id)autorelease NS_AUTOMATED_REFCOUNT_UNAVAILABLE;
- at end
-
- at interface NSObject <NSObject> {}
-- (id)init;
-
-+ (id)new;
-+ (id)alloc;
-- (void)dealloc;
-
-- (void)finalize;
-
-- (id)copy;
-- (id)mutableCopy;
- at end
-
-NS_AUTOMATED_REFCOUNT_UNAVAILABLE
- at interface NSAutoreleasePool : NSObject {
- at private
- void *_token;
- void *_reserved3;
- void *_reserved2;
- void *_reserved;
-}
-
-+ (void)addObject:(id)anObject;
-
-- (void)addObject:(id)anObject;
-
-- (void)drain;
-
- at end
-
-typedef const void* objc_objectptr_t;
-extern __attribute__((ns_returns_retained)) id objc_retainedObject(objc_objectptr_t __attribute__((cf_consumed)) pointer);
-extern __attribute__((ns_returns_not_retained)) id objc_unretainedObject(objc_objectptr_t pointer);
-extern objc_objectptr_t objc_unretainedPointer(id object);
-
-#define dispatch_retain(object) ({ dispatch_object_t _o = (object); _dispatch_object_validate(_o); (void)[_o retain]; })
-#define dispatch_release(object) ({ dispatch_object_t _o = (object); _dispatch_object_validate(_o); [_o release]; })
-#define xpc_retain(object) ({ xpc_object_t _o = (object); _xpc_object_validate(_o); [_o retain]; })
-#define xpc_release(object) ({ xpc_object_t _o = (object); _xpc_object_validate(_o); [_o release]; })
-
-typedef id dispatch_object_t;
-typedef id xpc_object_t;
-
-void _dispatch_object_validate(dispatch_object_t object);
-void _xpc_object_validate(xpc_object_t object);
-
-#if __has_feature(objc_arc)
-
-NS_INLINE CF_RETURNS_RETAINED CFTypeRef CFBridgingRetain(id X) {
- return (__bridge_retained CFTypeRef)X;
-}
-
-NS_INLINE id CFBridgingRelease(CFTypeRef CF_CONSUMED X) {
- return (__bridge_transfer id)X;
-}
-
-#else
-
-NS_INLINE CF_RETURNS_RETAINED CFTypeRef CFBridgingRetain(id X) {
- return X ? CFRetain((CFTypeRef)X) : NULL;
-}
-
-NS_INLINE id CFBridgingRelease(CFTypeRef CF_CONSUMED X) {
- return [(id)CFMakeCollectable(X) autorelease];
-}
-
-#endif
-
-void *_Block_copy(const void *aBlock);
-void _Block_release(const void *aBlock);
-#define Block_copy(...) ((__typeof(__VA_ARGS__))_Block_copy((const void *)(__VA_ARGS__)))
-#define Block_release(...) _Block_release((const void *)(__VA_ARGS__))
diff --git a/clang/test/ARCMT/GC-check-warn-nsalloc.m b/clang/test/ARCMT/GC-check-warn-nsalloc.m
deleted file mode 100644
index 1c33de5b65b256..00000000000000
--- a/clang/test/ARCMT/GC-check-warn-nsalloc.m
+++ /dev/null
@@ -1,10 +0,0 @@
-// RUN: %clang_cc1 -arcmt-action=check -no-ns-alloc-error -triple x86_64-apple-darwin10 -fobjc-gc-only %s 2>&1 | grep 'warning: \[rewriter\] call returns pointer to GC managed memory'
-// RUN: %clang_cc1 -arcmt-action=check -no-ns-alloc-error -triple x86_64-apple-darwin10 -fobjc-gc-only -x objective-c++ %s 2>&1 | grep 'warning: \[rewriter\] call returns pointer to GC managed memory'
-// TODO: Investigate VerifyDiagnosticConsumer failures on these tests when using -verify.
-
-typedef unsigned NSUInteger;
-void *__strong NSAllocateCollectable(NSUInteger size, NSUInteger options);
-
-void test1(void) {
- NSAllocateCollectable(100, 0);
-}
diff --git a/clang/test/ARCMT/GC-check.m b/clang/test/ARCMT/GC-check.m
deleted file mode 100644
index e95e285432e0f0..00000000000000
--- a/clang/test/ARCMT/GC-check.m
+++ /dev/null
@@ -1,19 +0,0 @@
-// RUN: %clang_cc1 -arcmt-action=check -verify -triple x86_64-apple-darwin10 -fobjc-gc-only %s
-// RUN: %clang_cc1 -arcmt-action=check -verify -triple x86_64-apple-darwin10 -fobjc-gc-only -x objective-c++ %s
-
-#define CF_AUTOMATED_REFCOUNT_UNAVAILABLE __attribute__((unavailable("not available in automatic reference counting mode")))
-typedef unsigned NSUInteger;
-typedef const void * CFTypeRef;
-CFTypeRef CFMakeCollectable(CFTypeRef cf) CF_AUTOMATED_REFCOUNT_UNAVAILABLE; // expected-note {{unavailable}}
-void *__strong NSAllocateCollectable(NSUInteger size, NSUInteger options);
-
-void test1(CFTypeRef *cft) {
- CFTypeRef c = CFMakeCollectable(cft); // expected-error {{CFMakeCollectable will leak the object that it receives in ARC}} \
- // expected-error {{unavailable}}
- NSAllocateCollectable(100, 0); // expected-error {{call returns pointer to GC managed memory; it will become unmanaged in ARC}}
-}
-
- at interface I1 {
- __strong void *gcVar; // expected-error {{GC managed memory will become unmanaged in ARC}}
-}
- at end;
diff --git a/clang/test/ARCMT/GC-no-arc-runtime.m b/clang/test/ARCMT/GC-no-arc-runtime.m
deleted file mode 100644
index 99ba2eb5f7aef3..00000000000000
--- a/clang/test/ARCMT/GC-no-arc-runtime.m
+++ /dev/null
@@ -1,80 +0,0 @@
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.6 -fsyntax-only -fobjc-runtime-has-weak -fobjc-arc -x objective-c %s.result
-// RUN: arcmt-test --args -triple x86_64-apple-macosx10.6 -fsyntax-only -fobjc-gc-only -x objective-c %s > %t
-// RUN: diff %t %s.result
-// RUN: arcmt-test --args -triple x86_64-apple-macosx10.6 -fsyntax-only -fobjc-gc-only -x objective-c++ %s > %t
-// RUN: diff %t %s.result
-
-// MRC __weak broke this test somehow.
-// XFAIL: *
-
-#include "Common.h"
-#include "GC.h"
-
-void test1(CFTypeRef *cft) {
- id x = NSMakeCollectable(cft);
-}
-
- at interface I1
- at end
-
- at implementation I1
--(void)dealloc {
- // dealloc
- test1(0);
-}
-
--(void)finalize {
- // finalize
- test1(0);
-}
- at end
-
- at interface I2
- at property (retain) id prop;
- at end
-
- at implementation I2
- at synthesize prop;
-
--(void)finalize {
- self.prop = 0;
- // finalize
- test1(0);
-}
- at end
-
-__attribute__((objc_arc_weak_reference_unavailable))
- at interface QQ {
- __weak id s;
- __weak QQ *q;
-}
- at end
-
- at interface I3
- at property (assign) I3 *__weak pw1, *__weak pw2;
- at property (assign) I3 *__strong ps;
- at property (assign) I3 * pds;
- at end
-
- at interface I4Impl {
- I4Impl *pds2;
-}
- at property (assign) I4Impl *__weak pw1, *__weak pw2;
- at property (assign) I4Impl *__strong ps;
- at property (assign) I4Impl * pds;
- at property (assign) I4Impl * pds2;
- at end
-
- at implementation I4Impl
- at synthesize pw1, pw2, ps, pds, pds2;
-
--(void)test1:(CFTypeRef *)cft {
- id x = NSMakeCollectable(cft);
-}
- at end
-
- at interface I5 {
- __weak id prop;
-}
- at property (readonly) __weak id prop;
- at end
diff --git a/clang/test/ARCMT/GC-no-arc-runtime.m.result b/clang/test/ARCMT/GC-no-arc-runtime.m.result
deleted file mode 100644
index c338bdb2ed471e..00000000000000
--- a/clang/test/ARCMT/GC-no-arc-runtime.m.result
+++ /dev/null
@@ -1,72 +0,0 @@
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.6 -fsyntax-only -fobjc-runtime-has-weak -fobjc-arc -x objective-c %s.result
-// RUN: arcmt-test --args -triple x86_64-apple-macosx10.6 -fsyntax-only -fobjc-gc-only -x objective-c %s > %t
-// RUN: diff %t %s.result
-// RUN: arcmt-test --args -triple x86_64-apple-macosx10.6 -fsyntax-only -fobjc-gc-only -x objective-c++ %s > %t
-// RUN: diff %t %s.result
-
-#include "Common.h"
-#include "GC.h"
-
-void test1(CFTypeRef *cft) {
- id x = CFBridgingRelease(cft);
-}
-
- at interface I1
- at end
-
- at implementation I1
--(void)dealloc {
- // dealloc
- test1(0);
-}
-
- at end
-
- at interface I2
- at property (strong) id prop;
- at end
-
- at implementation I2
- at synthesize prop;
-
--(void)dealloc {
- // finalize
- test1(0);
-}
- at end
-
-__attribute__((objc_arc_weak_reference_unavailable))
- at interface QQ {
- __unsafe_unretained id s;
- __unsafe_unretained QQ *q;
-}
- at end
-
- at interface I3
- at property (unsafe_unretained) I3 * pw1, * pw2;
- at property (strong) I3 * ps;
- at property (assign) I3 * pds;
- at end
-
- at interface I4Impl {
- I4Impl *__strong pds2;
-}
- at property (unsafe_unretained) I4Impl * pw1, * pw2;
- at property (strong) I4Impl * ps;
- at property (strong) I4Impl * pds;
- at property (strong) I4Impl * pds2;
- at end
-
- at implementation I4Impl
- at synthesize pw1, pw2, ps, pds, pds2;
-
--(void)test1:(CFTypeRef *)cft {
- id x = CFBridgingRelease(cft);
-}
- at end
-
- at interface I5 {
- __unsafe_unretained id prop;
-}
- at property (unsafe_unretained, readonly) id prop;
- at end
diff --git a/clang/test/ARCMT/GC-no-finalize-removal.m b/clang/test/ARCMT/GC-no-finalize-removal.m
deleted file mode 100644
index 07a737c1b7757e..00000000000000
--- a/clang/test/ARCMT/GC-no-finalize-removal.m
+++ /dev/null
@@ -1,88 +0,0 @@
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.7 -fsyntax-only -fobjc-runtime-has-weak -fobjc-arc -x objective-c %s.result
-// RUN: arcmt-test --args -triple x86_64-apple-macosx10.7 -fsyntax-only -fobjc-gc-only -no-finalize-removal -x objective-c %s > %t
-// RUN: diff %t %s.result
-// RUN: arcmt-test --args -triple x86_64-apple-macosx10.7 -fsyntax-only -fobjc-gc-only -no-finalize-removal -x objective-c++ %s > %t
-// RUN: diff %t %s.result
-
-#include "Common.h"
-#include "GC.h"
-
-void test1(CFTypeRef *cft) {
- id x = NSMakeCollectable(cft);
-}
-
- at interface I1
- at end
-
- at implementation I1
--(void)dealloc {
- // dealloc
- test1(0);
-}
-
--(void)finalize {
- // finalize
- test1(0);
-}
- at end
-
- at interface I2
- at property (retain) id prop;
- at end
-
- at implementation I2
- at synthesize prop;
-
--(void)finalize {
- self.prop = 0;
- // finalize
- test1(0);
-}
- at end
-
-__attribute__((objc_arc_weak_reference_unavailable))
- at interface QQ {
- __weak id s;
- __weak QQ *q;
-}
- at end
-
- at interface I3
- at property (assign) I3 *__weak pw1, *__weak pw2;
- at property (assign) I3 *__strong ps;
- at property (assign) I3 * pds;
- at end
-
- at interface I4Impl {
- I4Impl *pds2;
- I4Impl *pds3;
- __weak I4Impl *pw3;
- __weak I4Impl *pw4;
-}
- at property (assign) I4Impl *__weak pw1, *__weak pw2;
- at property (assign) I4Impl *__strong ps;
- at property (assign) I4Impl * pds;
- at property (assign) I4Impl * pds2;
- at property (readwrite) I4Impl * pds3;
- at property (readonly) I4Impl * pds4;
- at property (readonly) __weak I4Impl *pw3;
- at property (assign) __weak I4Impl *pw4;
- at end
-
- at implementation I4Impl
- at synthesize pw1, pw2, pw3, pw4, ps, pds, pds2, pds3, pds4;
-
--(void)test1:(CFTypeRef *)cft {
- id x = NSMakeCollectable(cft);
-}
- at end
-
- at interface rdar10532449
- at property (assign) id assign_prop;
- at property (assign, readonly) id __strong strong_readonly_prop;
- at property (assign) id __weak weak_prop;
- at end
-
- at implementation rdar10532449
- at synthesize assign_prop, strong_readonly_prop, weak_prop;
- at end
diff --git a/clang/test/ARCMT/GC-no-finalize-removal.m.result b/clang/test/ARCMT/GC-no-finalize-removal.m.result
deleted file mode 100644
index a2105b32fc755b..00000000000000
--- a/clang/test/ARCMT/GC-no-finalize-removal.m.result
+++ /dev/null
@@ -1,96 +0,0 @@
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.7 -fsyntax-only -fobjc-runtime-has-weak -fobjc-arc -x objective-c %s.result
-// RUN: arcmt-test --args -triple x86_64-apple-macosx10.7 -fsyntax-only -fobjc-gc-only -no-finalize-removal -x objective-c %s > %t
-// RUN: diff %t %s.result
-// RUN: arcmt-test --args -triple x86_64-apple-macosx10.7 -fsyntax-only -fobjc-gc-only -no-finalize-removal -x objective-c++ %s > %t
-// RUN: diff %t %s.result
-
-#include "Common.h"
-#include "GC.h"
-
-void test1(CFTypeRef *cft) {
- id x = CFBridgingRelease(cft);
-}
-
- at interface I1
- at end
-
- at implementation I1
--(void)dealloc {
- // dealloc
- test1(0);
-}
-
-#if !__has_feature(objc_arc)
--(void)finalize {
- // finalize
- test1(0);
-}
-#endif
- at end
-
- at interface I2
- at property (strong) id prop;
- at end
-
- at implementation I2
- at synthesize prop;
-
-#if !__has_feature(objc_arc)
--(void)finalize {
- self.prop = 0;
- // finalize
- test1(0);
-}
-#endif
--(void)dealloc {
- // finalize
- test1(0);
-}
- at end
-
-__attribute__((objc_arc_weak_reference_unavailable))
- at interface QQ {
- __weak id s;
- __unsafe_unretained QQ *q;
-}
- at end
-
- at interface I3
- at property (weak) I3 * pw1, * pw2;
- at property (strong) I3 * ps;
- at property (assign) I3 * pds;
- at end
-
- at interface I4Impl {
- I4Impl *__strong pds2;
- I4Impl *pds3;
- __weak I4Impl *pw3;
- __weak I4Impl *pw4;
-}
- at property (weak) I4Impl * pw1, * pw2;
- at property (strong) I4Impl * ps;
- at property (strong) I4Impl * pds;
- at property (strong) I4Impl * pds2;
- at property (readwrite) I4Impl * pds3;
- at property (readonly) I4Impl * pds4;
- at property (weak, readonly) I4Impl *pw3;
- at property (weak) I4Impl *pw4;
- at end
-
- at implementation I4Impl
- at synthesize pw1, pw2, pw3, pw4, ps, pds, pds2, pds3, pds4;
-
--(void)test1:(CFTypeRef *)cft {
- id x = CFBridgingRelease(cft);
-}
- at end
-
- at interface rdar10532449
- at property (strong) id assign_prop;
- at property (strong, readonly) id strong_readonly_prop;
- at property (weak) id weak_prop;
- at end
-
- at implementation rdar10532449
- at synthesize assign_prop, strong_readonly_prop, weak_prop;
- at end
diff --git a/clang/test/ARCMT/GC.h b/clang/test/ARCMT/GC.h
deleted file mode 100644
index 4301baf272465a..00000000000000
--- a/clang/test/ARCMT/GC.h
+++ /dev/null
@@ -1,6 +0,0 @@
-
- at interface ExtInterface {
- __strong ExtInterface *myivar;
- __strong void *gcVar;
-}
- at end
diff --git a/clang/test/ARCMT/GC.m b/clang/test/ARCMT/GC.m
deleted file mode 100644
index 97723e89ed369f..00000000000000
--- a/clang/test/ARCMT/GC.m
+++ /dev/null
@@ -1,93 +0,0 @@
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.7 -fsyntax-only -fobjc-runtime-has-weak -fobjc-arc -x objective-c %s.result
-// RUN: arcmt-test --args -triple x86_64-apple-macosx10.7 -fsyntax-only -fobjc-gc-only -x objective-c %s > %t
-// RUN: diff %t %s.result
-// RUN: arcmt-test --args -triple x86_64-apple-macosx10.7 -fsyntax-only -fobjc-gc-only -x objective-c++ %s > %t
-// RUN: diff %t %s.result
-
-#include "Common.h"
-#include "GC.h"
-
-void test1(CFTypeRef *cft) {
- id x = NSMakeCollectable(cft);
-}
-
- at interface I1
- at end
-
- at implementation I1
--(void)dealloc {
- // dealloc
- test1(0);
-}
-
--(void)finalize {
- // finalize
- test1(0);
-}
- at end
-
- at interface I2
- at property (retain) id prop;
- at end
-
- at implementation I2
- at synthesize prop;
-
--(void)finalize {
- self.prop = 0;
- // finalize
- test1(0);
-}
- at end
-
-__attribute__((objc_arc_weak_reference_unavailable))
- at interface QQ {
- __weak id s;
- __weak QQ *q;
-}
- at end
-
- at interface I3
- at property (assign) I3 *__weak pw1, *__weak pw2;
- at property (assign) I3 *__strong ps;
- at property (assign) I3 * pds;
- at end
-
- at interface I4Impl {
- I4Impl *pds2;
- I4Impl *pds3;
- __weak I4Impl *pw3;
- __weak I4Impl *pw4;
-}
- at property (assign) I4Impl *__weak pw1, *__weak pw2;
- at property (assign) I4Impl *__strong ps;
- at property (assign) I4Impl * pds;
- at property (assign) I4Impl * pds2;
- at property (readwrite) I4Impl * pds3;
- at property (readonly) I4Impl * pds4;
- at property (readonly) __weak I4Impl *pw3;
- at property (assign) __weak I4Impl *pw4;
- at end
-
- at implementation I4Impl
- at synthesize pw1, pw2, pw3, pw4, ps, pds, pds2, pds3, pds4;
-
--(void)test1:(CFTypeRef *)cft {
- id x = NSMakeCollectable(cft);
-}
- at end
-
- at interface rdar10532449
- at property (assign) id assign_prop;
- at property (assign, readonly) id __strong strong_readonly_prop;
- at property (assign) id __weak weak_prop;
- at end
-
- at implementation rdar10532449
- at synthesize assign_prop, strong_readonly_prop, weak_prop;
- at end
-
-void test2(id p, __strong I1 *ap[]) {
- for (__strong I1 *specRule in p) {
- }
-}
diff --git a/clang/test/ARCMT/GC.m.result b/clang/test/ARCMT/GC.m.result
deleted file mode 100644
index b60b07ac9c1109..00000000000000
--- a/clang/test/ARCMT/GC.m.result
+++ /dev/null
@@ -1,88 +0,0 @@
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.7 -fsyntax-only -fobjc-runtime-has-weak -fobjc-arc -x objective-c %s.result
-// RUN: arcmt-test --args -triple x86_64-apple-macosx10.7 -fsyntax-only -fobjc-gc-only -x objective-c %s > %t
-// RUN: diff %t %s.result
-// RUN: arcmt-test --args -triple x86_64-apple-macosx10.7 -fsyntax-only -fobjc-gc-only -x objective-c++ %s > %t
-// RUN: diff %t %s.result
-
-#include "Common.h"
-#include "GC.h"
-
-void test1(CFTypeRef *cft) {
- id x = CFBridgingRelease(cft);
-}
-
- at interface I1
- at end
-
- at implementation I1
--(void)dealloc {
- // dealloc
- test1(0);
-}
-
- at end
-
- at interface I2
- at property (strong) id prop;
- at end
-
- at implementation I2
- at synthesize prop;
-
--(void)dealloc {
- // finalize
- test1(0);
-}
- at end
-
-__attribute__((objc_arc_weak_reference_unavailable))
- at interface QQ {
- __weak id s;
- __unsafe_unretained QQ *q;
-}
- at end
-
- at interface I3
- at property (weak) I3 * pw1, * pw2;
- at property (strong) I3 * ps;
- at property (assign) I3 * pds;
- at end
-
- at interface I4Impl {
- I4Impl *__strong pds2;
- I4Impl *pds3;
- __weak I4Impl *pw3;
- __weak I4Impl *pw4;
-}
- at property (weak) I4Impl * pw1, * pw2;
- at property (strong) I4Impl * ps;
- at property (strong) I4Impl * pds;
- at property (strong) I4Impl * pds2;
- at property (readwrite) I4Impl * pds3;
- at property (readonly) I4Impl * pds4;
- at property (weak, readonly) I4Impl *pw3;
- at property (weak) I4Impl *pw4;
- at end
-
- at implementation I4Impl
- at synthesize pw1, pw2, pw3, pw4, ps, pds, pds2, pds3, pds4;
-
--(void)test1:(CFTypeRef *)cft {
- id x = CFBridgingRelease(cft);
-}
- at end
-
- at interface rdar10532449
- at property (strong) id assign_prop;
- at property (strong, readonly) id strong_readonly_prop;
- at property (weak) id weak_prop;
- at end
-
- at implementation rdar10532449
- at synthesize assign_prop, strong_readonly_prop, weak_prop;
- at end
-
-void test2(id p, __strong I1 *ap[]) {
- for (__strong I1 *specRule in p) {
- }
-}
diff --git a/clang/test/ARCMT/Inputs/Module.framework/Frameworks/SubFramework.framework/Headers/SubFramework.h b/clang/test/ARCMT/Inputs/Module.framework/Frameworks/SubFramework.framework/Headers/SubFramework.h
deleted file mode 100644
index f7f9fb66c9e945..00000000000000
--- a/clang/test/ARCMT/Inputs/Module.framework/Frameworks/SubFramework.framework/Headers/SubFramework.h
+++ /dev/null
@@ -1,5 +0,0 @@
-#ifndef MODULE_SUBFRAMEWORK_H
-#define MODULE_SUBFRAMEWORK_H
-#__private_macro MODULE_SUBFRAMEWORK_H
-char *module_subframework;
-#endif
diff --git a/clang/test/ARCMT/Inputs/Module.framework/Headers/Buried/Treasure.h b/clang/test/ARCMT/Inputs/Module.framework/Headers/Buried/Treasure.h
deleted file mode 100644
index 6e81adcb2b60c3..00000000000000
--- a/clang/test/ARCMT/Inputs/Module.framework/Headers/Buried/Treasure.h
+++ /dev/null
@@ -1 +0,0 @@
-unsigned *Buried_Treasure;
diff --git a/clang/test/ARCMT/Inputs/Module.framework/Headers/Module.h b/clang/test/ARCMT/Inputs/Module.framework/Headers/Module.h
deleted file mode 100644
index 3d2476b20431de..00000000000000
--- a/clang/test/ARCMT/Inputs/Module.framework/Headers/Module.h
+++ /dev/null
@@ -1,28 +0,0 @@
-// expected-warning 0-1 {{umbrella header}}
-
-// FIXME: The "umbrella header" warning should be moved to a separate test.
-// This "0-1" is only here because the warning is only emitted when the
-// module is (otherwise) successfully included.
-
-#ifndef MODULE_H
-#define MODULE_H
-const char *getModuleVersion(void);
-
-#ifdef FOO
-# error Module should have been built without -DFOO
-#endif
-
- at interface Module
-+(const char *)version; // retrieve module version
-+alloc;
- at end
-
-#define MODULE_H_MACRO 1
-#__private_macro MODULE_H_MACRO
-
-#include <Module/Sub.h>
-#include <Module/Buried/Treasure.h>
-
-__asm("foo");
-
-#endif // MODULE_H
diff --git a/clang/test/ARCMT/Inputs/Module.framework/Headers/NotInModule.h b/clang/test/ARCMT/Inputs/Module.framework/Headers/NotInModule.h
deleted file mode 100644
index 6b15791eb2c704..00000000000000
--- a/clang/test/ARCMT/Inputs/Module.framework/Headers/NotInModule.h
+++ /dev/null
@@ -1 +0,0 @@
-int not_in_module;
diff --git a/clang/test/ARCMT/Inputs/Module.framework/Headers/Sub.h b/clang/test/ARCMT/Inputs/Module.framework/Headers/Sub.h
deleted file mode 100644
index dea76e7646176d..00000000000000
--- a/clang/test/ARCMT/Inputs/Module.framework/Headers/Sub.h
+++ /dev/null
@@ -1,3 +0,0 @@
-#include <Module/Sub2.h>
-int *Module_Sub;
-
diff --git a/clang/test/ARCMT/Inputs/Module.framework/Headers/Sub2.h b/clang/test/ARCMT/Inputs/Module.framework/Headers/Sub2.h
deleted file mode 100644
index beed4a862dcaf7..00000000000000
--- a/clang/test/ARCMT/Inputs/Module.framework/Headers/Sub2.h
+++ /dev/null
@@ -1 +0,0 @@
-int *Module_Sub2;
diff --git a/clang/test/ARCMT/Inputs/Module.framework/Module b/clang/test/ARCMT/Inputs/Module.framework/Module
deleted file mode 100644
index e69de29bb2d1d6..00000000000000
diff --git a/clang/test/ARCMT/Inputs/Module.framework/PrivateHeaders/ModulePrivate.h b/clang/test/ARCMT/Inputs/Module.framework/PrivateHeaders/ModulePrivate.h
deleted file mode 100644
index 0782336df9dec0..00000000000000
--- a/clang/test/ARCMT/Inputs/Module.framework/PrivateHeaders/ModulePrivate.h
+++ /dev/null
@@ -1 +0,0 @@
-int module_private;
diff --git a/clang/test/ARCMT/Inputs/module.modulemap b/clang/test/ARCMT/Inputs/module.modulemap
deleted file mode 100644
index 061abbd24d570c..00000000000000
--- a/clang/test/ARCMT/Inputs/module.modulemap
+++ /dev/null
@@ -1,309 +0,0 @@
-module c_library [extern_c] { module inner { header "c-header.h" } }
-module cxx_library { header "cxx-header.h" requires cplusplus }
-module c_library_bad [extern_c] { header "c-header-bad.h" }
-module diamond_top { header "diamond_top.h" }
-module diamond_left {
- header "diamond_left.h"
- export diamond_top
-}
-module diamond_right {
- header "diamond_right.h"
- export diamond_top
-}
-module diamond_bottom {
- header "diamond_bottom.h"
- export *
-}
-module irgen { header "irgen.h" }
-module cxx_irgen_top { header "cxx-irgen-top.h" }
-module cxx_irgen_left { header "cxx-irgen-left.h" }
-module cxx_irgen_right { header "cxx-irgen-right.h" }
-module lookup_left_objc { header "lookup_left.h" }
-module lookup_right_objc { header "lookup_right.h" }
-module lookup_left_cxx { header "lookup_left.hpp" }
-module lookup_right_cxx { header "lookup_right.hpp" }
-module module_private_left { header "module_private_left.h" }
-module module_private_right { header "module_private_right.h" }
-module macros_top {
- header "macros_top.h"
- explicit module b { header "macros_top_b.h" }
- explicit module c { header "macros_top_c.h" }
-}
-module macros_left {
- header "macros_left.h"
- export *
-}
-module macros_right {
- header "macros_right.h"
- export *
- explicit module undef {
- header "macros_right_undef.h"
- }
-}
-module macros { header "macros.h" }
-module macros_other { header "macros_other.h" }
-module category_top { header "category_top.h" }
-module category_left {
- header "category_left.h"
- export category_top
-
- explicit module sub {
- header "category_left_sub.h"
- }
-}
-module category_right {
- header "category_right.h"
- export category_top
-
- explicit module sub {
- header "category_right_sub.h"
- }
-}
-module category_bottom {
- header "category_bottom.h"
- export category_left
- export category_right
-}
-module category_other { header "category_other.h" }
-module redeclarations_left { header "redeclarations_left.h" }
-module redeclarations_right { header "redeclarations_right.h" }
-module redecl_namespaces_left { header "redecl_namespaces_left.h" }
-module redecl_namespaces_right { header "redecl_namespaces_right.h" }
-module redecl_add_after_load_top { header "redecl-add-after-load-top.h" }
-module redecl_add_after_load { header "redecl-add-after-load.h" }
-module load_failure { header "load_failure.h" }
-
-module decldef {
- explicit module Decl { header "decl.h" }
- explicit module Decl2 { header "decl2.h" }
- explicit module Def { header "def.h" }
-}
-
-module redecl_merge_top {
- header "redecl-merge-top.h"
- explicit module Explicit { header "redecl-merge-top-explicit.h" }
- exclude header "nonexistent.h"
-}
-module redecl_merge_left {
- header "redecl-merge-left.h"
- export *
-}
-module redecl_merge_left_left {
- header "redecl-merge-left-left.h"
- export *
-}
-module redecl_merge_right {
- header "redecl-merge-right.h"
- export *
-}
-module redecl_merge_bottom {
- explicit module prefix {
- header "redecl-merge-bottom-prefix.h"
- }
-
- header "redecl-merge-bottom.h"
- export *
-}
-module namespaces_top {
- header "namespaces-top.h"
- export *
-}
-module namespaces_left {
- header "namespaces-left.h"
- export *
-}
-module namespaces_right {
- header "namespaces-right.h"
- export *
-}
-module templates_top {
- header "templates-top.h"
- export *
-}
-module templates_left {
- header "templates-left.h"
- export *
-}
-module templates_right {
- header "templates-right.h"
- export *
-}
-module MethodPoolA {
- header "MethodPoolA.h"
-
- explicit module Sub2 {
- header "MethodPoolASub2.h"
- }
-
- explicit module Sub {
- header "MethodPoolASub.h"
- }
-}
-module MethodPoolB {
- header "MethodPoolB.h"
-
- explicit module Sub2 {
- header "MethodPoolBSub2.h"
- }
-
- explicit module Sub {
- header "MethodPoolBSub.h"
- }
-}
-module import_decl {
- header "import-decl.h"
-}
-
-framework module * {
- exclude NotAModule
-}
-
-module linkage_merge_left {
- explicit module sub {
- header "linkage-merge-sub.h"
- }
-}
-
-module autolink {
- header "autolink.h"
- link "autolink"
-
- explicit module sub {
- header "autolink-sub.h"
- link "autolink_sub"
- }
-
- explicit module sub2 {
- header "autolink-sub2.h"
- link framework "autolink_framework"
- }
-
- explicit module sub3 {
- header "autolink-sub3.h"
- link "autolink_from_pch"
- }
-}
-
-module weird_objc {
- header "weird_objc.h"
-}
-
-module ignored_macros {
- header "ignored_macros.h"
-}
-
-module cxx_many_overloads {
- header "cxx-many-overloads.h"
-}
-
-module cxx_inline_namespace {
- header "cxx-inline-namespace.h"
-}
-
-module cxx_inline_namespace_b {
- header "cxx-inline-namespace-b.h"
-}
-
-module cxx_linkage_cache {
- header "cxx-linkage-cache.h"
-}
-
-module cxx_templates_common {
- header "cxx-templates-common.h"
-}
-
-module cxx_templates_a {
- header "cxx-templates-a.h"
-}
-
-module cxx_templates_b_impl {
- header "cxx-templates-b-impl.h"
-}
-
-module cxx_templates_b {
- header "cxx-templates-b.h"
-}
-
-module cxx_templates_c {
- header "cxx-templates-c.h"
-}
-
-module cxx_decls {
- module unimported {
- header "cxx-decls-unimported.h"
- }
- module imported {
- header "cxx-decls-imported.h"
- }
-}
-
-module config {
- header "config.h"
- config_macros [exhaustive] WANT_FOO, WANT_BAR
-}
-
-module diag_pragma {
- header "diag_pragma.h"
-}
-
-module dummy {
- header "dummy.h"
-}
-
-module builtin {
- header "builtin.h"
- explicit module sub {
- header "builtin_sub.h"
- }
-}
-
-module linkage_merge {
- explicit module foo {
- header "linkage-merge-foo.h"
- }
- explicit module bar {
- header "linkage-merge-bar.h"
- }
-
-}
-
-module incomplete_mod {
- header "incomplete_mod.h"
-}
-
-module warning {
- header "warning.h"
-}
-
-module initializer_list {
- header "initializer_list"
-}
-
-module using_decl {
- module a { header "using-decl-a.h" export * }
- module b { header "using-decl-b.h" export * }
-}
-
-module recursive_visibility_a1 {
- module inner { header "recursive_visibility_a1_inner.h" }
-}
-module recursive_visibility_a2 {
- module inner {
- module more_inner {
- header "recursive_visibility_a2_more_inner.h"
- }
- }
-}
-module recursive_visibility_b {
- header "recursive_visibility_b.h"
- export *
-}
-module recursive_visibility_c {
- header "recursive_visibility_c.h"
-}
-module recursive1 {
- header "recursive1.h"
-}
-module recursive2 {
- header "recursive2.h"
-}
diff --git a/clang/test/ARCMT/Inputs/test.h b/clang/test/ARCMT/Inputs/test.h
deleted file mode 100644
index 756295f27e6983..00000000000000
--- a/clang/test/ARCMT/Inputs/test.h
+++ /dev/null
@@ -1,15 +0,0 @@
- at protocol NSObject
-- (oneway void)release;
- at end
-
-#ifdef PART1
-static inline void part1(id p) {
- [p release];
-}
-#endif
-
-#ifdef PART2
-static inline void part2(id p) {
- [p release];
-}
-#endif
diff --git a/clang/test/ARCMT/Inputs/test.h.result b/clang/test/ARCMT/Inputs/test.h.result
deleted file mode 100644
index 0638a3378c1c06..00000000000000
--- a/clang/test/ARCMT/Inputs/test.h.result
+++ /dev/null
@@ -1,13 +0,0 @@
- at protocol NSObject
-- (oneway void)release;
- at end
-
-#ifdef PART1
-static inline void part1(id p) {
-}
-#endif
-
-#ifdef PART2
-static inline void part2(id p) {
-}
-#endif
diff --git a/clang/test/ARCMT/Inputs/test1.m.in b/clang/test/ARCMT/Inputs/test1.m.in
deleted file mode 100644
index 44a3c4cf3d93fc..00000000000000
--- a/clang/test/ARCMT/Inputs/test1.m.in
+++ /dev/null
@@ -1,16 +0,0 @@
-#define PART1
-#include "test.h"
-
-void test1(id p) {
- [p release];
-}
-
- at interface Test2
- at property (strong) id prop;
- at end
-
- at implementation Test2
--(id)init {
- _prop = 0;
-}
- at end
diff --git a/clang/test/ARCMT/Inputs/test1.m.in.result b/clang/test/ARCMT/Inputs/test1.m.in.result
deleted file mode 100644
index 1db9bf7ad65c79..00000000000000
--- a/clang/test/ARCMT/Inputs/test1.m.in.result
+++ /dev/null
@@ -1,15 +0,0 @@
-#define PART1
-#include "test.h"
-
-void test1(id p) {
-}
-
- at interface Test2
- at property (strong) id prop;
- at end
-
- at implementation Test2
--(id)init {
- _prop = 0;
-}
- at end
diff --git a/clang/test/ARCMT/Inputs/test2.m.in b/clang/test/ARCMT/Inputs/test2.m.in
deleted file mode 100644
index 99f87b0721716a..00000000000000
--- a/clang/test/ARCMT/Inputs/test2.m.in
+++ /dev/null
@@ -1,6 +0,0 @@
-#define PART2
-#include "test.h"
-
-void test2(id p) {
- [p release];
-}
diff --git a/clang/test/ARCMT/Inputs/test2.m.in.result b/clang/test/ARCMT/Inputs/test2.m.in.result
deleted file mode 100644
index f8e918ce2598e5..00000000000000
--- a/clang/test/ARCMT/Inputs/test2.m.in.result
+++ /dev/null
@@ -1,5 +0,0 @@
-#define PART2
-#include "test.h"
-
-void test2(id p) {
-}
diff --git a/clang/test/ARCMT/Inputs/with space/test.h b/clang/test/ARCMT/Inputs/with space/test.h
deleted file mode 100644
index 756295f27e6983..00000000000000
--- a/clang/test/ARCMT/Inputs/with space/test.h
+++ /dev/null
@@ -1,15 +0,0 @@
- at protocol NSObject
-- (oneway void)release;
- at end
-
-#ifdef PART1
-static inline void part1(id p) {
- [p release];
-}
-#endif
-
-#ifdef PART2
-static inline void part2(id p) {
- [p release];
-}
-#endif
diff --git a/clang/test/ARCMT/Inputs/with space/test.h.result b/clang/test/ARCMT/Inputs/with space/test.h.result
deleted file mode 100644
index 0638a3378c1c06..00000000000000
--- a/clang/test/ARCMT/Inputs/with space/test.h.result
+++ /dev/null
@@ -1,13 +0,0 @@
- at protocol NSObject
-- (oneway void)release;
- at end
-
-#ifdef PART1
-static inline void part1(id p) {
-}
-#endif
-
-#ifdef PART2
-static inline void part2(id p) {
-}
-#endif
diff --git a/clang/test/ARCMT/Inputs/with space/test1.m.in b/clang/test/ARCMT/Inputs/with space/test1.m.in
deleted file mode 100644
index 8416a889656960..00000000000000
--- a/clang/test/ARCMT/Inputs/with space/test1.m.in
+++ /dev/null
@@ -1,6 +0,0 @@
-#define PART1
-#include "test.h"
-
-void test1(id p) {
- [p release];
-}
diff --git a/clang/test/ARCMT/Inputs/with space/test1.m.in.result b/clang/test/ARCMT/Inputs/with space/test1.m.in.result
deleted file mode 100644
index f351fe6c835522..00000000000000
--- a/clang/test/ARCMT/Inputs/with space/test1.m.in.result
+++ /dev/null
@@ -1,5 +0,0 @@
-#define PART1
-#include "test.h"
-
-void test1(id p) {
-}
diff --git a/clang/test/ARCMT/Inputs/with space/test2.m.in b/clang/test/ARCMT/Inputs/with space/test2.m.in
deleted file mode 100644
index 99f87b0721716a..00000000000000
--- a/clang/test/ARCMT/Inputs/with space/test2.m.in
+++ /dev/null
@@ -1,6 +0,0 @@
-#define PART2
-#include "test.h"
-
-void test2(id p) {
- [p release];
-}
diff --git a/clang/test/ARCMT/Inputs/with space/test2.m.in.result b/clang/test/ARCMT/Inputs/with space/test2.m.in.result
deleted file mode 100644
index f8e918ce2598e5..00000000000000
--- a/clang/test/ARCMT/Inputs/with space/test2.m.in.result
+++ /dev/null
@@ -1,5 +0,0 @@
-#define PART2
-#include "test.h"
-
-void test2(id p) {
-}
diff --git a/clang/test/ARCMT/allowlisted/Inputs/header1.h b/clang/test/ARCMT/allowlisted/Inputs/header1.h
deleted file mode 100644
index 44430f3b77e328..00000000000000
--- a/clang/test/ARCMT/allowlisted/Inputs/header1.h
+++ /dev/null
@@ -1 +0,0 @@
-// the contents are not important
diff --git a/clang/test/ARCMT/allowlisted/header1.h b/clang/test/ARCMT/allowlisted/header1.h
deleted file mode 100644
index 33f77aa5dd1527..00000000000000
--- a/clang/test/ARCMT/allowlisted/header1.h
+++ /dev/null
@@ -1,8 +0,0 @@
-
- at interface I1 : NSObject
--(int)prop;
--(void)setProp:(int)p;
-+(id)i1;
- at end
-
-typedef long NSInteger;
diff --git a/clang/test/ARCMT/allowlisted/header1.h.result b/clang/test/ARCMT/allowlisted/header1.h.result
deleted file mode 100644
index c7cf109a27e92c..00000000000000
--- a/clang/test/ARCMT/allowlisted/header1.h.result
+++ /dev/null
@@ -1,7 +0,0 @@
-
- at interface I1 : NSObject
- at property (nonatomic) int prop;
-+(instancetype)i1;
- at end
-
-typedef long NSInteger;
diff --git a/clang/test/ARCMT/allowlisted/header2.h b/clang/test/ARCMT/allowlisted/header2.h
deleted file mode 100644
index ac3888ccdf8c11..00000000000000
--- a/clang/test/ARCMT/allowlisted/header2.h
+++ /dev/null
@@ -1,8 +0,0 @@
-
-#define NS_ENUM(_type, _name) enum _name : _type _name; enum _name : _type
-typedef enum : NSInteger {five} ApplicableEnum;
-
- at interface I2 : NSObject
--(int)prop;
--(void)setProp:(int)p;
- at end
diff --git a/clang/test/ARCMT/allowlisted/header2.h.result b/clang/test/ARCMT/allowlisted/header2.h.result
deleted file mode 100644
index 3226e711b98acb..00000000000000
--- a/clang/test/ARCMT/allowlisted/header2.h.result
+++ /dev/null
@@ -1,7 +0,0 @@
-
-#define NS_ENUM(_type, _name) enum _name : _type _name; enum _name : _type
-typedef NS_ENUM(NSInteger, ApplicableEnum) {five};
-
- at interface I2 : NSObject
- at property (nonatomic) int prop;
- at end
diff --git a/clang/test/ARCMT/allowlisted/objcmt-with-allowlist-impl.m b/clang/test/ARCMT/allowlisted/objcmt-with-allowlist-impl.m
deleted file mode 100644
index 36797eb1c843b4..00000000000000
--- a/clang/test/ARCMT/allowlisted/objcmt-with-allowlist-impl.m
+++ /dev/null
@@ -1,18 +0,0 @@
-// RUN: rm -rf %t
-// RUN: %clang_cc1 -objcmt-migrate-readwrite-property -objcmt-migrate-instancetype -objcmt-allowlist-dir-path=%S/Inputs %s -triple x86_64-apple-darwin11 -migrate -o %t.remap
-// RUN: c-arcmt-test %t.remap | arcmt-test -verify-transformed-files %S/header1.h.result %s.result
-
- at interface NSObject
-+ (id)alloc;
- at end
-
-#include "header1.h"
-#include "header2.h"
-
- at interface I2(cat)
--(id)initInCat;
- at end
-
- at implementation I1
-+(id)i1 {}
- at end
diff --git a/clang/test/ARCMT/allowlisted/objcmt-with-allowlist-impl.m.result b/clang/test/ARCMT/allowlisted/objcmt-with-allowlist-impl.m.result
deleted file mode 100644
index 69e7b767ef2b70..00000000000000
--- a/clang/test/ARCMT/allowlisted/objcmt-with-allowlist-impl.m.result
+++ /dev/null
@@ -1,18 +0,0 @@
-// RUN: rm -rf %t
-// RUN: %clang_cc1 -objcmt-migrate-readwrite-property -objcmt-migrate-instancetype -objcmt-allowlist-dir-path=%S/Inputs %s -triple x86_64-apple-darwin11 -migrate -o %t.remap
-// RUN: c-arcmt-test %t.remap | arcmt-test -verify-transformed-files %S/header1.h.result %s.result
-
- at interface NSObject
-+ (id)alloc;
- at end
-
-#include "header1.h"
-#include "header2.h"
-
- at interface I2(cat)
--(id)initInCat;
- at end
-
- at implementation I1
-+(instancetype)i1 {}
- at end
diff --git a/clang/test/ARCMT/allowlisted/objcmt-with-allowlist.m b/clang/test/ARCMT/allowlisted/objcmt-with-allowlist.m
deleted file mode 100644
index c22c02d3bf2e43..00000000000000
--- a/clang/test/ARCMT/allowlisted/objcmt-with-allowlist.m
+++ /dev/null
@@ -1,12 +0,0 @@
-// RUN: rm -rf %t
-// RUN: %clang_cc1 -objcmt-migrate-readwrite-property -objcmt-migrate-instancetype -objcmt-migrate-ns-macros %s -triple x86_64-apple-darwin11 -migrate -o %t.remap
-// RUN: c-arcmt-test %t.remap | arcmt-test -verify-transformed-files %S/header1.h.result %S/header2.h.result
-// RUN: %clang_cc1 -objcmt-migrate-readwrite-property -objcmt-migrate-instancetype -objcmt-migrate-ns-macros -objcmt-allowlist-dir-path=%S/Inputs %s -triple x86_64-apple-darwin11 -migrate -o %t.remap
-// RUN: c-arcmt-test %t.remap | arcmt-test -verify-transformed-files %S/header1.h.result
-
- at interface NSObject
-+ (id)alloc;
- at end
-
-#include "header1.h"
-#include "header2.h"
diff --git a/clang/test/ARCMT/api.m b/clang/test/ARCMT/api.m
deleted file mode 100644
index b186ec724745cc..00000000000000
--- a/clang/test/ARCMT/api.m
+++ /dev/null
@@ -1,9 +0,0 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result
-// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s > %t
-// RUN: diff %t %s.result
-
-#include "Common.h"
-
-void test(NSObject *o) {
- NSZone *z = [o zone];
-}
diff --git a/clang/test/ARCMT/api.m.result b/clang/test/ARCMT/api.m.result
deleted file mode 100644
index e3093751b626b8..00000000000000
--- a/clang/test/ARCMT/api.m.result
+++ /dev/null
@@ -1,9 +0,0 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result
-// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s > %t
-// RUN: diff %t %s.result
-
-#include "Common.h"
-
-void test(NSObject *o) {
- NSZone *z = nil;
-}
diff --git a/clang/test/ARCMT/assign-prop-no-arc-runtime.m b/clang/test/ARCMT/assign-prop-no-arc-runtime.m
deleted file mode 100644
index de1c456b3d19f4..00000000000000
--- a/clang/test/ARCMT/assign-prop-no-arc-runtime.m
+++ /dev/null
@@ -1,15 +0,0 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result
-// RUN: arcmt-test --args -triple x86_64-apple-macosx10.6 -fsyntax-only %s > %t
-// RUN: diff %t %s.result
-
-#include "Common.h"
-
- at interface Foo : NSObject {
- NSObject *x;
-}
- at property (readonly,assign) id x;
- at end
-
- at implementation Foo
- at synthesize x;
- at end
diff --git a/clang/test/ARCMT/assign-prop-no-arc-runtime.m.result b/clang/test/ARCMT/assign-prop-no-arc-runtime.m.result
deleted file mode 100644
index 23848d357268f6..00000000000000
--- a/clang/test/ARCMT/assign-prop-no-arc-runtime.m.result
+++ /dev/null
@@ -1,15 +0,0 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result
-// RUN: arcmt-test --args -triple x86_64-apple-macosx10.6 -fsyntax-only %s > %t
-// RUN: diff %t %s.result
-
-#include "Common.h"
-
- at interface Foo : NSObject {
- NSObject *__unsafe_unretained x;
-}
- at property (readonly,unsafe_unretained) id x;
- at end
-
- at implementation Foo
- at synthesize x;
- at end
diff --git a/clang/test/ARCMT/assign-prop-with-arc-runtime.m b/clang/test/ARCMT/assign-prop-with-arc-runtime.m
deleted file mode 100644
index a00538cd6197d6..00000000000000
--- a/clang/test/ARCMT/assign-prop-with-arc-runtime.m
+++ /dev/null
@@ -1,72 +0,0 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -fobjc-runtime-has-weak -x objective-c %s.result
-// RUN: arcmt-test --args -triple x86_64-apple-macosx10.7 -fsyntax-only %s > %t
-// RUN: diff %t %s.result
-
-#include "Common.h"
-
-__attribute__((objc_arc_weak_reference_unavailable))
- at interface WeakOptOut
- at end
-
- at class _NSCachedAttributedString;
-typedef _NSCachedAttributedString *BadClassForWeak;
-
- at class Forw;
-
- at interface Foo : NSObject {
- Foo *x, *w, *q1, *q2;
- WeakOptOut *oo;
- BadClassForWeak bcw;
- id not_safe1;
- NSObject *not_safe2;
- Forw *not_safe3;
- Foo *assign_plus1;
-}
- at property (readonly) Foo *x;
- at property (assign) Foo *w;
- at property Foo *q1, *q2;
- at property (assign) WeakOptOut *oo;
- at property (assign) BadClassForWeak bcw;
- at property (assign) id not_safe1;
- at property () NSObject *not_safe2;
- at property Forw *not_safe3;
- at property (readonly) Foo *assign_plus1;
- at property (readonly) Foo *assign_plus2;
- at property (readonly) Foo *assign_plus3;
-
- at property (assign) Foo *no_user_ivar1;
- at property (readonly) Foo *no_user_ivar2;
-
- at property (retain) id def1;
- at property (atomic,retain) id def2;
- at property (retain,atomic) id def3;
-
- at end
-
- at implementation Foo
- at synthesize x,w,q1,q2,oo,bcw,not_safe1,not_safe2,not_safe3;
- at synthesize no_user_ivar1, no_user_ivar2;
- at synthesize assign_plus1, assign_plus2, assign_plus3;
- at synthesize def1, def2, def3;
-
--(void)test:(Foo *)parm {
- assign_plus1 = [[Foo alloc] init];
- assign_plus2 = [Foo new];
- assign_plus3 = [parm retain];
-}
- at end
-
- at interface TestExt
- at property (retain,readonly) TestExt *x1;
- at property (readonly) TestExt *x2;
- at end
-
- at interface TestExt()
- at property (retain,readwrite) TestExt *x1;
- at property (readwrite) TestExt *x2;
- at property (retain) TestExt *x3;
- at end
-
- at implementation TestExt
- at synthesize x1, x2, x3;
- at end
diff --git a/clang/test/ARCMT/assign-prop-with-arc-runtime.m.result b/clang/test/ARCMT/assign-prop-with-arc-runtime.m.result
deleted file mode 100644
index 8bb684f79a3399..00000000000000
--- a/clang/test/ARCMT/assign-prop-with-arc-runtime.m.result
+++ /dev/null
@@ -1,72 +0,0 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -fobjc-runtime-has-weak -x objective-c %s.result
-// RUN: arcmt-test --args -triple x86_64-apple-macosx10.7 -fsyntax-only %s > %t
-// RUN: diff %t %s.result
-
-#include "Common.h"
-
-__attribute__((objc_arc_weak_reference_unavailable))
- at interface WeakOptOut
- at end
-
- at class _NSCachedAttributedString;
-typedef _NSCachedAttributedString *BadClassForWeak;
-
- at class Forw;
-
- at interface Foo : NSObject {
- Foo *__weak x, *__weak w, *__weak q1, *__weak q2;
- WeakOptOut *__unsafe_unretained oo;
- BadClassForWeak __unsafe_unretained bcw;
- id __unsafe_unretained not_safe1;
- NSObject *__unsafe_unretained not_safe2;
- Forw *__unsafe_unretained not_safe3;
- Foo *assign_plus1;
-}
- at property (weak, readonly) Foo *x;
- at property (weak) Foo *w;
- at property (weak) Foo *q1, *q2;
- at property (unsafe_unretained) WeakOptOut *oo;
- at property (unsafe_unretained) BadClassForWeak bcw;
- at property (unsafe_unretained) id not_safe1;
- at property (unsafe_unretained) NSObject *not_safe2;
- at property (unsafe_unretained) Forw *not_safe3;
- at property (readonly) Foo *assign_plus1;
- at property (readonly) Foo *assign_plus2;
- at property (readonly) Foo *assign_plus3;
-
- at property (weak) Foo *no_user_ivar1;
- at property (weak, readonly) Foo *no_user_ivar2;
-
- at property (strong) id def1;
- at property (atomic,strong) id def2;
- at property (strong,atomic) id def3;
-
- at end
-
- at implementation Foo
- at synthesize x,w,q1,q2,oo,bcw,not_safe1,not_safe2,not_safe3;
- at synthesize no_user_ivar1, no_user_ivar2;
- at synthesize assign_plus1, assign_plus2, assign_plus3;
- at synthesize def1, def2, def3;
-
--(void)test:(Foo *)parm {
- assign_plus1 = [[Foo alloc] init];
- assign_plus2 = [Foo new];
- assign_plus3 = parm;
-}
- at end
-
- at interface TestExt
- at property (strong,readonly) TestExt *x1;
- at property (weak, readonly) TestExt *x2;
- at end
-
- at interface TestExt()
- at property (strong,readwrite) TestExt *x1;
- at property (weak, readwrite) TestExt *x2;
- at property (strong) TestExt *x3;
- at end
-
- at implementation TestExt
- at synthesize x1, x2, x3;
- at end
diff --git a/clang/test/ARCMT/atautorelease-2.m b/clang/test/ARCMT/atautorelease-2.m
deleted file mode 100644
index b9bc1065532597..00000000000000
--- a/clang/test/ARCMT/atautorelease-2.m
+++ /dev/null
@@ -1,29 +0,0 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result
-// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s > %t
-// RUN: diff %t %s.result
-
- at interface NSAutoreleasePool
-- drain;
-+new;
-+alloc;
--init;
--autorelease;
--release;
- at end
-
-void NSLog(id, ...);
-
-int main (int argc, const char * argv[]) {
- NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
- NSAutoreleasePool *chunkPool = [[NSAutoreleasePool alloc] init];
-
- while (argc) {
- [chunkPool release];
- return 0;
- }
-
- [chunkPool drain];
- [pool drain];
-
- return 0;
-}
diff --git a/clang/test/ARCMT/atautorelease-2.m.result b/clang/test/ARCMT/atautorelease-2.m.result
deleted file mode 100644
index 205473380b7391..00000000000000
--- a/clang/test/ARCMT/atautorelease-2.m.result
+++ /dev/null
@@ -1,28 +0,0 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result
-// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s > %t
-// RUN: diff %t %s.result
-
- at interface NSAutoreleasePool
-- drain;
-+new;
-+alloc;
--init;
--autorelease;
--release;
- at end
-
-void NSLog(id, ...);
-
-int main (int argc, const char * argv[]) {
- @autoreleasepool {
- @autoreleasepool {
-
- while (argc) {
- return 0;
- }
-
- }
- }
-
- return 0;
-}
diff --git a/clang/test/ARCMT/atautorelease-3.m b/clang/test/ARCMT/atautorelease-3.m
deleted file mode 100644
index 87b80af9350eb0..00000000000000
--- a/clang/test/ARCMT/atautorelease-3.m
+++ /dev/null
@@ -1,40 +0,0 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result
-// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s > %t
-// RUN: diff %t %s.result
-
- at interface NSAutoreleasePool
-- drain;
-+new;
-+alloc;
--init;
--autorelease;
-- release;
- at end
-
-void NSLog(id, ...);
-
-void test1(int x) {
- // All this stuff get removed since nothing is happening inside.
- NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
- NSAutoreleasePool *chunkPool = [[NSAutoreleasePool alloc] init];
- while (x) {
- chunkPool = [[NSAutoreleasePool alloc] init];
- [chunkPool release];
- }
-
- [chunkPool drain];
- [pool drain];
-}
-
-void test2(int x) {
- NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
- NSAutoreleasePool *chunkPool = [[NSAutoreleasePool alloc] init];
- while (x) {
- chunkPool = [[NSAutoreleasePool alloc] init];
- ++x;
- [chunkPool release];
- }
-
- [chunkPool drain];
- [pool drain];
-}
diff --git a/clang/test/ARCMT/atautorelease-3.m.result b/clang/test/ARCMT/atautorelease-3.m.result
deleted file mode 100644
index 801376a7e82bda..00000000000000
--- a/clang/test/ARCMT/atautorelease-3.m.result
+++ /dev/null
@@ -1,31 +0,0 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result
-// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s > %t
-// RUN: diff %t %s.result
-
- at interface NSAutoreleasePool
-- drain;
-+new;
-+alloc;
--init;
--autorelease;
-- release;
- at end
-
-void NSLog(id, ...);
-
-void test1(int x) {
- // All this stuff get removed since nothing is happening inside.
-}
-
-void test2(int x) {
- @autoreleasepool {
- @autoreleasepool {
- while (x) {
- @autoreleasepool {
- ++x;
- }
- }
-
- }
- }
-}
diff --git a/clang/test/ARCMT/atautorelease-check.m b/clang/test/ARCMT/atautorelease-check.m
deleted file mode 100644
index 5f8ffa8bc40ee2..00000000000000
--- a/clang/test/ARCMT/atautorelease-check.m
+++ /dev/null
@@ -1,144 +0,0 @@
-// RUN: %clang_cc1 -arcmt-action=check -verify -triple x86_64-apple-darwin10 %s
-
-#if __has_feature(objc_arr)
-#define NS_AUTOMATED_REFCOUNT_UNAVAILABLE __attribute__((unavailable("not available in automatic reference counting mode")))
-#else
-#define NS_AUTOMATED_REFCOUNT_UNAVAILABLE
-#endif
-
-typedef struct _NSZone NSZone;
-typedef int BOOL;
-typedef unsigned NSUInteger;
-
- at protocol NSObject
-- (BOOL)isEqual:(id)object;
-- (id)retain NS_AUTOMATED_REFCOUNT_UNAVAILABLE;
-- (NSUInteger)retainCount NS_AUTOMATED_REFCOUNT_UNAVAILABLE;
-- (oneway void)release NS_AUTOMATED_REFCOUNT_UNAVAILABLE;
-- (id)autorelease NS_AUTOMATED_REFCOUNT_UNAVAILABLE;
-
-- (NSZone *)zone NS_AUTOMATED_REFCOUNT_UNAVAILABLE;
- at end
-
- at protocol NSCopying
-- (id)copyWithZone:(NSZone *)zone;
- at end
-
- at protocol NSMutableCopying
-- (id)mutableCopyWithZone:(NSZone *)zone;
- at end
-
- at interface NSObject <NSObject> {}
-- (id)init;
-
-+ (id)new;
-+ (id)allocWithZone:(NSZone *)zone NS_AUTOMATED_REFCOUNT_UNAVAILABLE;
-+ (id)alloc;
-- (void)dealloc;
-
-- (void)finalize;
-
-- (id)copy;
-- (id)mutableCopy;
-
-+ (id)copyWithZone:(NSZone *)zone NS_AUTOMATED_REFCOUNT_UNAVAILABLE;
-+ (id)mutableCopyWithZone:(NSZone *)zone NS_AUTOMATED_REFCOUNT_UNAVAILABLE;
- at end
-
-extern void NSRecycleZone(NSZone *zone);
-
-NS_AUTOMATED_REFCOUNT_UNAVAILABLE
- at interface NSAutoreleasePool : NSObject { // expected-note 13 {{marked unavailable here}}
- at private
- void *_token;
- void *_reserved3;
- void *_reserved2;
- void *_reserved;
-}
-
-+ (void)addObject:(id)anObject;
-
-- (void)addObject:(id)anObject;
-
-- (void)drain;
-
- at end
-
-
-void NSLog(id, ...);
-
-int main (int argc, const char * argv[]) {
- NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
- NSAutoreleasePool *chunkPool = [[NSAutoreleasePool alloc] init]; // expected-error 2 {{'NSAutoreleasePool' is unavailable}}
-
- while (argc) {
- [chunkPool release];
- // the following pool was not released in this scope, don't touch it.
- chunkPool = [[NSAutoreleasePool alloc] init]; // expected-error {{'NSAutoreleasePool' is unavailable}}
- }
-
- [chunkPool drain];
- [pool drain];
-
- return 0;
-}
-
-void f(void) {
- NSAutoreleasePool * pool; // expected-error {{'NSAutoreleasePool' is unavailable}}
-
- for (int i=0; i != 10; ++i) {
- id x = pool; // We won't touch a NSAutoreleasePool if we can't safely
- // remove all the references to it.
- }
-
- pool = [[NSAutoreleasePool alloc] init]; // expected-error {{'NSAutoreleasePool' is unavailable}}
- NSLog(@"%s", "YES");
- [pool release];
-}
-
-void f2(void) {
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; // expected-error 2 {{'NSAutoreleasePool' is unavailable}} \
- // expected-note {{scope begins here}}
-
- // 'x' is declared inside the "pool scope" but used outside it, if we create
- // a @autorelease scope it will be undefined outside it so don't touch the pool.
- int x = 0; // expected-note {{declared here}}
-
- [pool release]; // expected-note {{scope ends here}}
-
- ++x; // expected-error {{a name is referenced outside the NSAutoreleasePool scope that it was declared in}}
-}
-
-void f3(void) {
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; // expected-error 2 {{'NSAutoreleasePool' is unavailable}} \
- // expected-note {{scope begins here}}
-
- struct S { int x; }; // expected-note {{declared here}}
-
- [pool release]; // expected-note {{scope ends here}}
-
- struct S *var; // expected-error {{a name is referenced outside the NSAutoreleasePool scope that it was declared in}}
- var->x = 0;
-}
-
-void f4(void) {
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; // expected-error 2 {{'NSAutoreleasePool' is unavailable}} \
- // expected-note {{scope begins here}}
-
- enum { Bar }; // expected-note {{declared here}}
-
- [pool release]; // expected-note {{scope ends here}}
-
- int x = Bar; // expected-error {{a name is referenced outside the NSAutoreleasePool scope that it was declared in}}
-}
-
-void f5(void) {
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; // expected-error 2 {{'NSAutoreleasePool' is unavailable}} \
- // expected-note {{scope begins here}}
-
- typedef int Bar; // expected-note {{declared here}}
-
- [pool release]; // expected-note {{scope ends here}}
-
- Bar x; // expected-error {{a name is referenced outside the NSAutoreleasePool scope that it was declared in}}
-}
diff --git a/clang/test/ARCMT/atautorelease.m b/clang/test/ARCMT/atautorelease.m
deleted file mode 100644
index a6aed146497b43..00000000000000
--- a/clang/test/ARCMT/atautorelease.m
+++ /dev/null
@@ -1,61 +0,0 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result
-// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s > %t
-// RUN: diff %t %s.result
-
-#include "Common.h"
-
-void NSLog(id, ...);
-
-int main (int argc, const char * argv[]) {
-
- NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
-
- if (argc) {
- NSAutoreleasePool * pool = [NSAutoreleasePool new];
- NSLog(@"%s", "YES");
- [pool drain];
- }
- [pool drain];
-
- NSAutoreleasePool * pool1 = [[NSAutoreleasePool alloc] init];
- NSLog(@"%s", "YES");
- [pool1 release];
-
- return 0;
-}
-
-void f(void) {
- NSAutoreleasePool *pool1;
-
- pool1 = [NSAutoreleasePool new];
- int x = 4;
-
- NSAutoreleasePool *pool2 = [[NSAutoreleasePool alloc] init];
- ++x;
- [pool2 drain];
-
- [pool1 release];
-}
-
-int UIApplicationMain(int argc, char *argv[]);
-
-int main2(int argc, char *argv[]) {
- NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
- int result = UIApplicationMain(argc, argv);
- [pool release];
- return result;
-}
-
- at interface Foo : NSObject
- at property (assign) id myProp;
- at end
-
- at implementation Foo
- at synthesize myProp;
-
--(void)test:(id)p {
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
- [pool drain];
- self.myProp = p;
-}
- at end
diff --git a/clang/test/ARCMT/atautorelease.m.result b/clang/test/ARCMT/atautorelease.m.result
deleted file mode 100644
index e24339a3b9e36b..00000000000000
--- a/clang/test/ARCMT/atautorelease.m.result
+++ /dev/null
@@ -1,60 +0,0 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result
-// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s > %t
-// RUN: diff %t %s.result
-
-#include "Common.h"
-
-void NSLog(id, ...);
-
-int main (int argc, const char * argv[]) {
-
- @autoreleasepool {
-
- if (argc) {
- @autoreleasepool {
- NSLog(@"%s", "YES");
- }
- }
- }
-
- @autoreleasepool {
- NSLog(@"%s", "YES");
- }
-
- return 0;
-}
-
-void f(void) {
-
- @autoreleasepool {
- int x = 4;
-
- @autoreleasepool {
- ++x;
- }
-
- }
-}
-
-int UIApplicationMain(int argc, char *argv[]);
-
-int main2(int argc, char *argv[]) {
- @autoreleasepool {
- int result = UIApplicationMain(argc, argv);
- return result;
- }
-}
-
- at interface Foo : NSObject
- at property (unsafe_unretained) id myProp;
- at end
-
- at implementation Foo
- at synthesize myProp;
-
--(void)test:(id)p {
- @autoreleasepool {
- }
- self.myProp = p;
-}
- at end
diff --git a/clang/test/ARCMT/autoreleases.m b/clang/test/ARCMT/autoreleases.m
deleted file mode 100644
index 4c268c09a715c6..00000000000000
--- a/clang/test/ARCMT/autoreleases.m
+++ /dev/null
@@ -1,75 +0,0 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result
-// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s > %t
-// RUN: diff %t %s.result
-
-#include "Common.h"
-
- at interface A : NSObject {
- at package
- id object;
-}
- at end
-
- at interface B : NSObject {
- id _prop;
- xpc_object_t _xpc_prop;
-}
-- (BOOL)containsSelf:(A*)a;
- at property (retain) id prop;
- at property (retain) xpc_object_t xpc_prop;
- at end
-
- at implementation A
- at end
-
- at implementation B
-- (BOOL)containsSelf:(A*)a {
- return a->object == self;
-}
-
--(id) prop {
- return _prop;
-}
--(void) setProp:(id) newVal {
- [_prop autorelease];
- _prop = [newVal retain];
-}
--(void) setProp2:(CFTypeRef) newVal {
- [_prop autorelease];
- _prop = (id)CFRetain(newVal);
-}
-
--(id) xpc_prop {
- return _xpc_prop;
-}
--(void) setXpc_prop:(xpc_object_t) newVal {
- [_xpc_prop autorelease];
- _xpc_prop = xpc_retain(newVal);
-}
- at end
-
-void NSLog(id, ...);
-
-int main (int argc, const char * argv[]) {
- NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
- A *a = [[A new] autorelease];
- B *b = [[B new] autorelease];
- NSLog(@"%s", [b containsSelf:a] ? "YES" : "NO");
- [pool drain];
- return 0;
-}
-
-void test(A *prevVal, A *newVal) {
- [prevVal autorelease];
- prevVal = [newVal retain];
-}
-
-id test2(A* val) {
- [[val retain] autorelease];
- return val;
-}
-
-id test3(void) {
- id a = [[A alloc] init];
- [a autorelease];
-}
diff --git a/clang/test/ARCMT/autoreleases.m.result b/clang/test/ARCMT/autoreleases.m.result
deleted file mode 100644
index b3aad804a45be6..00000000000000
--- a/clang/test/ARCMT/autoreleases.m.result
+++ /dev/null
@@ -1,69 +0,0 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result
-// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s > %t
-// RUN: diff %t %s.result
-
-#include "Common.h"
-
- at interface A : NSObject {
- at package
- id object;
-}
- at end
-
- at interface B : NSObject {
- id _prop;
- xpc_object_t _xpc_prop;
-}
-- (BOOL)containsSelf:(A*)a;
- at property (strong) id prop;
- at property (strong) xpc_object_t xpc_prop;
- at end
-
- at implementation A
- at end
-
- at implementation B
-- (BOOL)containsSelf:(A*)a {
- return a->object == self;
-}
-
--(id) prop {
- return _prop;
-}
--(void) setProp:(id) newVal {
- _prop = newVal;
-}
--(void) setProp2:(CFTypeRef) newVal {
- _prop = (id)CFBridgingRelease(CFRetain(newVal));
-}
-
--(id) xpc_prop {
- return _xpc_prop;
-}
--(void) setXpc_prop:(xpc_object_t) newVal {
- _xpc_prop = newVal;
-}
- at end
-
-void NSLog(id, ...);
-
-int main (int argc, const char * argv[]) {
- @autoreleasepool {
- A *a = [A new];
- B *b = [B new];
- NSLog(@"%s", [b containsSelf:a] ? "YES" : "NO");
- }
- return 0;
-}
-
-void test(A *prevVal, A *newVal) {
- prevVal = newVal;
-}
-
-id test2(A* val) {
- return val;
-}
-
-id test3(void) {
- id a = [[A alloc] init];
-}
diff --git a/clang/test/ARCMT/block_copy_release.m b/clang/test/ARCMT/block_copy_release.m
deleted file mode 100644
index ae3b82660a8e43..00000000000000
--- a/clang/test/ARCMT/block_copy_release.m
+++ /dev/null
@@ -1,17 +0,0 @@
-// RUN: %clang_cc1 -fblocks -fsyntax-only -fobjc-arc -x objective-c %s.result
-// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fblocks -fsyntax-only -x objective-c %s > %t
-// RUN: diff %t %s.result
-
-#include "Common.h"
-
-typedef void (^blk)(int);
-
-void func(blk b) {
- blk c = Block_copy(b);
- Block_release(c);
-}
-
-void func2(id b) {
- id c = Block_copy(b);
- Block_release(c);
-}
diff --git a/clang/test/ARCMT/block_copy_release.m.result b/clang/test/ARCMT/block_copy_release.m.result
deleted file mode 100644
index b292b64f17d6bc..00000000000000
--- a/clang/test/ARCMT/block_copy_release.m.result
+++ /dev/null
@@ -1,15 +0,0 @@
-// RUN: %clang_cc1 -fblocks -fsyntax-only -fobjc-arc -x objective-c %s.result
-// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fblocks -fsyntax-only -x objective-c %s > %t
-// RUN: diff %t %s.result
-
-#include "Common.h"
-
-typedef void (^blk)(int);
-
-void func(blk b) {
- blk c = [b copy];
-}
-
-void func2(id b) {
- id c = [b copy];
-}
diff --git a/clang/test/ARCMT/check-api.m b/clang/test/ARCMT/check-api.m
deleted file mode 100644
index b395f0b4a4b975..00000000000000
--- a/clang/test/ARCMT/check-api.m
+++ /dev/null
@@ -1,43 +0,0 @@
-// RUN: %clang_cc1 -arcmt-action=check -verify -triple x86_64-apple-macosx10.7 %s
-
-#include "Common.h"
-
- at interface NSInvocation : NSObject
-- (void)getReturnValue:(void *)retLoc;
-- (void)setReturnValue:(void *)retLoc;
-
-- (void)getArgument:(void *)argumentLocation atIndex:(int)idx;
-- (void)setArgument:(void *)argumentLocation atIndex:(int)idx;
- at end
-
- at interface Test
- at end
-
- at implementation Test {
- id strong_id;
- __weak id weak_id;
- __unsafe_unretained id unsafe_id;
- int arg;
-}
-- (void) test:(NSInvocation *)invok {
- [invok getReturnValue:&strong_id]; // expected-error {{NSInvocation's getReturnValue is not safe to be used with an object with ownership other than __unsafe_unretained}}
- [invok getReturnValue:&weak_id]; // expected-error {{NSInvocation's getReturnValue is not safe to be used with an object with ownership other than __unsafe_unretained}}
- [invok getReturnValue:&unsafe_id];
- [invok getReturnValue:&arg];
-
- [invok setReturnValue:&strong_id]; // expected-error {{NSInvocation's setReturnValue is not safe to be used with an object with ownership other than __unsafe_unretained}}
- [invok setReturnValue:&weak_id]; // expected-error {{NSInvocation's setReturnValue is not safe to be used with an object with ownership other than __unsafe_unretained}}
- [invok setReturnValue:&unsafe_id];
- [invok setReturnValue:&arg];
-
- [invok getArgument:&strong_id atIndex:0]; // expected-error {{NSInvocation's getArgument is not safe to be used with an object with ownership other than __unsafe_unretained}}
- [invok getArgument:&weak_id atIndex:0]; // expected-error {{NSInvocation's getArgument is not safe to be used with an object with ownership other than __unsafe_unretained}}
- [invok getArgument:&unsafe_id atIndex:0];
- [invok getArgument:&arg atIndex:0];
-
- [invok setArgument:&strong_id atIndex:0]; // expected-error {{NSInvocation's setArgument is not safe to be used with an object with ownership other than __unsafe_unretained}}
- [invok setArgument:&weak_id atIndex:0]; // expected-error {{NSInvocation's setArgument is not safe to be used with an object with ownership other than __unsafe_unretained}}
- [invok setArgument:&unsafe_id atIndex:0];
- [invok setArgument:&arg atIndex:0];
-}
- at end
diff --git a/clang/test/ARCMT/check-with-pch.m b/clang/test/ARCMT/check-with-pch.m
deleted file mode 100644
index c2fda3b52cbc98..00000000000000
--- a/clang/test/ARCMT/check-with-pch.m
+++ /dev/null
@@ -1,15 +0,0 @@
-// RUN: %clang_cc1 -x objective-c -triple x86_64-apple-darwin10 %S/Common.h -emit-pch -o %t.pch
-// RUN: %clang_cc1 -include-pch %t.pch -arcmt-action=check -verify -triple x86_64-apple-darwin10 -fblocks -Werror %s
-// REQUIRES: x86-registered-target
-
- at interface I9601437 {
- __unsafe_unretained id x;
-}
--(void)Meth;
- at end
-
- at implementation I9601437
--(void)Meth {
- self->x = [NSObject new]; // expected-error {{assigning retained object}}
-}
- at end
diff --git a/clang/test/ARCMT/check-with-serialized-diag.m b/clang/test/ARCMT/check-with-serialized-diag.m
deleted file mode 100644
index 6102be037fcc1a..00000000000000
--- a/clang/test/ARCMT/check-with-serialized-diag.m
+++ /dev/null
@@ -1,55 +0,0 @@
-
- at protocol NSObject
-- (id)retain;
-- (unsigned)retainCount;
-- (oneway void)release;
-- (id)autorelease;
- at end
-
- at interface NSObject <NSObject> {}
-- (id)init;
-
-+ (id)new;
-+ (id)alloc;
-- (void)dealloc;
-
-- (void)finalize;
-
-- (id)copy;
-- (id)mutableCopy;
- at end
-
- at interface A : NSObject
- at end
-
-struct UnsafeS {
- A *__unsafe_unretained unsafeObj;
-};
-
-id global_foo;
-
-void test1(A *a, struct UnsafeS *unsafeS) {
- [unsafeS->unsafeObj retain];
- id foo = [unsafeS->unsafeObj retain]; // no warning.
- [global_foo retain];
- [a retainCount];
-}
-
-// RUN: not %clang_cc1 -arcmt-action=check -triple x86_64-apple-darwin10 %s -serialize-diagnostic-file %t.diag
-// RUN: c-index-test -read-diagnostics %t.diag > %t 2>&1
-// RUN: FileCheck --input-file=%t %s
-
-// CHECK: {{.*}}check-with-serialized-diag.m:32:4: error: [rewriter] it is not safe to remove 'retain' message on an __unsafe_unretained type
-// CHECK-NEXT: Number FIXITs = 0
-// CHECK-NEXT: {{.*}}check-with-serialized-diag.m:34:4: error: [rewriter] it is not safe to remove 'retain' message on a global variable
-// CHECK-NEXT: Number FIXITs = 0
-// CHECK-NEXT: {{.*}}check-with-serialized-diag.m:32:23: error: ARC forbids explicit message send of 'retain'
-// CHECK-NEXT: Range: {{.*}}check-with-serialized-diag.m:32:4 {{.*}}check-with-serialized-diag.m:32:22
-// CHECK-NEXT: Number FIXITs = 0
-// CHECK-NEXT: {{.*}}check-with-serialized-diag.m:34:15: error: ARC forbids explicit message send of 'retain'
-// CHECK-NEXT: Range: {{.*}}check-with-serialized-diag.m:34:4 {{.*}}check-with-serialized-diag.m:34:14
-// CHECK-NEXT: Number FIXITs = 0
-// CHECK-NEXT: {{.*}}check-with-serialized-diag.m:35:6: error: ARC forbids explicit message send of 'retainCount'
-// CHECK-NEXT: Range: {{.*}}check-with-serialized-diag.m:35:4 {{.*}}check-with-serialized-diag.m:35:5
-// CHECK-NEXT: Number FIXITs = 0
-
diff --git a/clang/test/ARCMT/checking-in-arc.m b/clang/test/ARCMT/checking-in-arc.m
deleted file mode 100644
index 1bf6aca18a3428..00000000000000
--- a/clang/test/ARCMT/checking-in-arc.m
+++ /dev/null
@@ -1,50 +0,0 @@
-// RUN: %clang_cc1 -arcmt-action=check -fobjc-arc -fobjc-runtime=macosx-10.8.0 -triple x86_64-apple-darwin12 -fblocks -Werror %s
-
-#if __has_feature(objc_arc)
-#define NS_AUTOMATED_REFCOUNT_UNAVAILABLE __attribute__((unavailable("not available in automatic reference counting mode")))
-#else
-#define NS_AUTOMATED_REFCOUNT_UNAVAILABLE
-#endif
-
-typedef const void * CFTypeRef;
-CFTypeRef CFBridgingRetain(id X);
-id CFBridgingRelease(CFTypeRef);
-
-typedef int BOOL;
-typedef unsigned NSUInteger;
-
- at protocol NSObject
-- (id)retain NS_AUTOMATED_REFCOUNT_UNAVAILABLE;
-- (NSUInteger)retainCount NS_AUTOMATED_REFCOUNT_UNAVAILABLE;
-- (oneway void)release NS_AUTOMATED_REFCOUNT_UNAVAILABLE;
-- (id)autorelease NS_AUTOMATED_REFCOUNT_UNAVAILABLE;
- at end
-
- at interface NSObject <NSObject> {}
-- (id)init;
-
-+ (id)new;
-+ (id)alloc;
-- (void)dealloc;
-
-- (void)finalize;
-
-- (id)copy;
-- (id)mutableCopy;
- at end
-
-typedef const struct __CFString * CFStringRef;
-extern const CFStringRef kUTTypePlainText;
-extern const CFStringRef kUTTypeRTF;
- at class NSString;
-
- at interface Test : NSObject
- at property (weak) NSString *weakProperty;
- at end
-
- at implementation Test
- at end
-
-#if ! __has_feature(objc_arc)
-#error This file must be compiled with ARC (set -fobjc_arc flag on file)
-#endif
diff --git a/clang/test/ARCMT/checking.m b/clang/test/ARCMT/checking.m
deleted file mode 100644
index 5bc456c6301c08..00000000000000
--- a/clang/test/ARCMT/checking.m
+++ /dev/null
@@ -1,351 +0,0 @@
-// RUN: %clang_cc1 -arcmt-action=check -verify -triple x86_64-apple-darwin10 -fblocks -Werror %s
-
-#if __has_feature(objc_arc)
-#define NS_AUTOMATED_REFCOUNT_UNAVAILABLE __attribute__((unavailable("not available in automatic reference counting mode")))
-#else
-#define NS_AUTOMATED_REFCOUNT_UNAVAILABLE
-#endif
-
-typedef const void * CFTypeRef;
-CFTypeRef CFBridgingRetain(id X);
-id CFBridgingRelease(CFTypeRef);
-
-typedef int BOOL;
-typedef unsigned NSUInteger;
-
- at protocol NSObject
-- (id)retain NS_AUTOMATED_REFCOUNT_UNAVAILABLE;
-- (NSUInteger)retainCount NS_AUTOMATED_REFCOUNT_UNAVAILABLE;
-- (oneway void)release NS_AUTOMATED_REFCOUNT_UNAVAILABLE;
-- (id)autorelease NS_AUTOMATED_REFCOUNT_UNAVAILABLE;
- at end
-
- at interface NSObject <NSObject> {}
-- (id)init;
-
-+ (id)new;
-+ (id)alloc;
-- (void)dealloc;
-
-- (void)finalize;
-
-- (id)copy;
-- (id)mutableCopy;
- at end
-
-typedef const struct __CFString * CFStringRef;
-extern const CFStringRef kUTTypePlainText;
-extern const CFStringRef kUTTypeRTF;
- at class NSString;
- at class A;
-
-struct UnsafeS {
- A *__unsafe_unretained unsafeObj;
-};
-
- at interface A : NSObject
-- (id)retain __attribute__((unavailable)); // expected-note {{'retain' has been explicitly marked unavailable here}}
-- (id)retainCount __attribute__((unavailable)); // expected-note {{'retainCount' has been explicitly marked unavailable here}}
-- (id)autorelease __attribute__((unavailable)); // expected-note 2 {{'autorelease' has been explicitly marked unavailable here}}
-- (id)init;
-- (oneway void)release;
-- (void)dealloc;
--(void)test;
--(id)delegate;
- at end
-
- at implementation A
--(void)test {
- [super dealloc];
-}
--(void)dealloc {
- [super dealloc];
-}
-
-- (id)retain { return self; } // expected-error {{ARC forbids implementation}}
-- (id)retainCount { return self; } // expected-error {{ARC forbids implementation}}
-- (id)autorelease { return self; } // expected-error {{ARC forbids implementation}}
-- (oneway void)release { } // expected-error {{ARC forbids implementation}}
-
--(id)delegate { return self; }
- at end
-
-id global_foo;
-
-void test1(A *a, BOOL b, struct UnsafeS *unsafeS) {
- [[a delegate] release]; // expected-error {{it is not safe to remove 'retain' message on the result of a 'delegate' message; the object that was passed to 'setDelegate:' may not be properly retained}} \
- // expected-error {{ARC forbids explicit message send}}
- [a.delegate release]; // expected-error {{it is not safe to remove 'retain' message on the result of a 'delegate' message; the object that was passed to 'setDelegate:' may not be properly retained}} \
- // expected-error {{ARC forbids explicit message send}}
- [unsafeS->unsafeObj retain]; // expected-error {{it is not safe to remove 'retain' message on an __unsafe_unretained type}} \
- // expected-error {{ARC forbids explicit message send}} \
- // expected-error {{'retain' is unavailable}}
- id foo = [unsafeS->unsafeObj retain]; // no warning.
- [global_foo retain]; // expected-error {{it is not safe to remove 'retain' message on a global variable}} \
- // expected-error {{ARC forbids explicit message send}}
- [global_foo release]; // expected-error {{it is not safe to remove 'release' message on a global variable}} \
- // expected-error {{ARC forbids explicit message send}}
- [a dealloc];
- [a retain];
- [a retainCount]; // expected-error {{ARC forbids explicit message send of 'retainCount'}} \
- // expected-error {{'retainCount' is unavailable}}
- [a release];
- [a autorelease]; // expected-error {{it is not safe to remove an unused 'autorelease' message; its receiver may be destroyed immediately}} \
- // expected-error {{ARC forbids explicit message send}} \
- // expected-error {{'autorelease' is unavailable}}
- [a autorelease]; // expected-error {{it is not safe to remove an unused 'autorelease' message; its receiver may be destroyed immediately}} \
- // expected-error {{ARC forbids explicit message send}} \
- // expected-error {{'autorelease' is unavailable}}
- a = 0;
-
- CFStringRef cfstr;
- NSString *str = (NSString *)cfstr; // expected-error {{cast of C pointer type 'CFStringRef' (aka 'const struct __CFString *') to Objective-C pointer type 'NSString *' requires a bridged cast}} \
- // expected-note {{use __bridge to convert directly (no change in ownership)}} \
- // expected-note {{use CFBridgingRelease call to transfer ownership of a +1 'CFStringRef' (aka 'const struct __CFString *') into ARC}} \
- str = (NSString *)kUTTypePlainText;
- str = b ? kUTTypeRTF : kUTTypePlainText;
- str = (NSString *)(b ? kUTTypeRTF : kUTTypePlainText);
- str = (NSString *)a; // no change.
-
- SEL s = @selector(retain); // expected-error {{ARC forbids use of 'retain' in a @selector}}
- s = @selector(release); // expected-error {{ARC forbids use of 'release' in a @selector}}
- s = @selector(autorelease); // expected-error {{ARC forbids use of 'autorelease' in a @selector}}
- s = @selector(dealloc); // expected-error {{ARC forbids use of 'dealloc' in a @selector}}
-
- static id __autoreleasing X1; // expected-error {{global variables cannot have __autoreleasing ownership}}
-}
-
-struct S {
- A* a;
-};
-
- at interface B
--(id)alloc;
-- (id)initWithInt: (int) i;
- at end
-
-void rdar8861761(void) {
- B *o1 = [[B alloc] initWithInt:0];
- B *o2 = [B alloc];
- [o2 initWithInt:0];
-}
-
- at interface Test13
-- (id) init0;
-- (void) noninit;
- at end
- at implementation Test13
-- (id) init0 {
- self = 0;
-}
-- (void) noninit {
- self = 0; // expected-error {{cannot assign to 'self' outside of a method in the init family}}
-
- for (__strong id x in collection) { // expected-error {{use of undeclared identifier 'collection'}}
- x = 0;
- }
-}
- at end
-
-void * cvt(id arg)
-{
- void* voidp_val;
- (void)(int*)arg; // expected-error {{disallowed}}
- (void)(id)arg;
- (void)(__autoreleasing id*)arg; // expected-error {{disallowed}}
- (void)(id*)arg; // expected-error {{disallowed}}
-
- (void)(__autoreleasing id**)voidp_val;
- (void)(void*)voidp_val;
- (void)(void**)arg; // expected-error {{disallowed}}
- cvt((void*)arg); // expected-error 2 {{requires a bridged cast}} \
- // expected-note 2 {{use __bridge to}} expected-note {{use CFBridgingRelease call}} expected-note {{use CFBridgingRetain call}}
- cvt(0);
- (void)(__strong id**)(0);
- return arg; // expected-error {{requires a bridged cast}} expected-note {{use __bridge}} expected-note {{use CFBridgingRetain call}}
-}
-
-
-void test12(id collection) {
- for (id x in collection) {
- x = 0;
- }
-
- for (__strong id x in collection) {
- x = 0;
- }
-}
-
-void test6(unsigned cond) {
- switch (cond) {
- case 0:
- ;
- id x; // expected-note {{jump bypasses initialization of __strong variable}}
-
- case 1: // expected-error {{cannot jump}}
- x = 0;
- break;
- }
-}
-
- at class Test8_incomplete;
- at interface Test8_complete @end;
- at interface Test8_super @end;
- at interface Test8 : Test8_super
-- (id) init00;
-- (id) init01; // expected-note {{declaration in interface}}
-- (id) init02;
-- (id) init03; // covariance
-- (id) init04; // covariance
-- (id) init05;
-
-- (void) init10; // expected-note {{declaration in interface is not in the 'init' family because its result type is not an object pointer}}
-- (void) init11;
-- (void) init12;
-- (void) init13; // expected-note {{declaration in interface is not in the 'init' family because its result type is not an object pointer}}
-- (void) init14; // expected-note {{declaration in interface is not in the 'init' family because its result type is not an object pointer}}
-- (void) init15;
-
-// These should be invalid to actually call.
-- (Test8_incomplete*) init20;
-- (Test8_incomplete*) init21; // expected-note {{declaration in interface}}
-- (Test8_incomplete*) init22;
-- (Test8_incomplete*) init23;
-- (Test8_incomplete*) init24;
-- (Test8_incomplete*) init25;
-
-- (Test8_super*) init30; // id exception to covariance
-- (Test8_super*) init31; // expected-note {{declaration in interface}}
-- (Test8_super*) init32;
-- (Test8_super*) init33;
-- (Test8_super*) init34; // covariance
-- (Test8_super*) init35;
-
-- (Test8*) init40; // id exception to covariance
-- (Test8*) init41; // expected-note {{declaration in interface}}
-- (Test8*) init42;
-- (Test8*) init43; // this should be a warning, but that's a general language thing, not an ARC thing
-- (Test8*) init44;
-- (Test8*) init45;
-
-- (Test8_complete*) init50; // expected-error {{init methods must return a type related to the receiver type}}
-- (Test8_complete*) init51; // expected-error {{init methods must return a type related to the receiver type}}
-- (Test8_complete*) init52; // expected-error {{init methods must return a type related to the receiver type}}
-- (Test8_complete*) init53; // expected-error {{init methods must return a type related to the receiver type}}
-- (Test8_complete*) init54; // expected-error {{init methods must return a type related to the receiver type}}
-- (Test8_complete*) init55; // expected-error {{init methods must return a type related to the receiver type}}
- at end
- at implementation Test8
-- (id) init00 { return 0; }
-- (id) init10 { return 0; } // expected-error {{method implementation does not match its declaration}}
-- (id) init20 { return 0; }
-- (id) init30 { return 0; }
-- (id) init40 { return 0; }
-- (id) init50 { return 0; }
-
-- (void) init01 {} // expected-error {{method was declared as an 'init' method, but its implementation doesn't match because its result type is not an object pointer}}
-- (void) init11 {}
-- (void) init21 {} // expected-error {{method was declared as an 'init' method, but its implementation doesn't match because its result type is not an object pointer}}
-- (void) init31 {} // expected-error {{method was declared as an 'init' method, but its implementation doesn't match because its result type is not an object pointer}}
-- (void) init41 {} // expected-error {{method was declared as an 'init' method, but its implementation doesn't match because its result type is not an object pointer}}
-- (void) init51 {}
-
-- (Test8_incomplete*) init02 { return 0; } // expected-error {{init methods must return a type related to the receiver type}}
-- (Test8_incomplete*) init12 { return 0; } // expected-error {{init methods must return a type related to the receiver type}}
-- (Test8_incomplete*) init22 { return 0; } // expected-error {{init methods must return a type related to the receiver type}}
-- (Test8_incomplete*) init32 { return 0; } // expected-error {{init methods must return a type related to the receiver type}}
-- (Test8_incomplete*) init42 { return 0; } // expected-error {{init methods must return a type related to the receiver type}}
-- (Test8_incomplete*) init52 { return 0; } // expected-error {{init methods must return a type related to the receiver type}}
-
-- (Test8_super*) init03 { return 0; }
-- (Test8_super*) init13 { return 0; } // expected-error {{method implementation does not match its declaration}}
-- (Test8_super*) init23 { return 0; }
-- (Test8_super*) init33 { return 0; }
-- (Test8_super*) init43 { return 0; }
-- (Test8_super*) init53 { return 0; }
-
-- (Test8*) init04 { return 0; }
-- (Test8*) init14 { return 0; } // expected-error {{method implementation does not match its declaration}}
-- (Test8*) init24 { return 0; }
-- (Test8*) init34 { return 0; }
-- (Test8*) init44 { return 0; }
-- (Test8*) init54 { return 0; }
-
-- (Test8_complete*) init05 { return 0; } // expected-error {{init methods must return a type related to the receiver type}}
-- (Test8_complete*) init15 { return 0; } // expected-error {{init methods must return a type related to the receiver type}}
-- (Test8_complete*) init25 { return 0; } // expected-error {{init methods must return a type related to the receiver type}}
-- (Test8_complete*) init35 { return 0; } // expected-error {{init methods must return a type related to the receiver type}}
-- (Test8_complete*) init45 { return 0; } // expected-error {{init methods must return a type related to the receiver type}}
-- (Test8_complete*) init55 { return 0; } // expected-error {{init methods must return a type related to the receiver type}}
- at end
-
- at class Test9_incomplete;
- at interface Test9
-- (Test9_incomplete*) init1; // expected-error {{init methods must return a type related to the receiver type}}
-- (Test9_incomplete*) init2;
- at end
-id test9(Test9 *v) {
- return [v init1];
-}
-
-void rdar9491791(int p) {
- switch (p) {
- case 3:;
- NSObject *o = [[NSObject alloc] init];
- [o release];
- break;
- default:
- break;
- }
-}
-
-#define RELEASE_MACRO(x) do { [x release]; } while(1)
-
-void rdar9504750(id p) {
- RELEASE_MACRO(p); // expected-error {{ARC forbids explicit message send of 'release'}}
-}
-
- at interface TestReadonlyProperty : NSObject
- at property(assign,readonly) NSObject *value;
- at end
-
- at implementation TestReadonlyProperty
- at synthesize value;
-- (void)viewDidLoad {
- value = [NSObject new]; // expected-error {{assigning retained object}}
-}
- at end
-
- at interface I9601437 {
- __unsafe_unretained id x;
-}
--(void)Meth;
- at end
-
- at implementation I9601437
--(void)Meth {
- self->x = [NSObject new]; // expected-error {{assigning retained object}}
-}
- at end
-
- at interface Test10 : NSObject {
- CFStringRef cfstr;
-}
- at property (retain) id prop;
--(void)foo;
- at end
-
-void test(Test10 *x) {
- x.prop = ^{ [x foo]; }; // expected-warning {{likely to lead to a retain cycle}} \
- // expected-note {{retained by the captured object}}
-}
-
- at implementation Test10
--(void)foo {
- ^{
- NSString *str = (NSString *)cfstr; // expected-error {{cast of C pointer type 'CFStringRef' (aka 'const struct __CFString *') to Objective-C pointer type 'NSString *' requires a bridged cast}} \
- // expected-note {{use __bridge to convert directly (no change in ownership)}} \
- // expected-note {{use CFBridgingRelease call to transfer ownership of a +1 'CFStringRef' (aka 'const struct __CFString *') into ARC}}
- };
-}
- at end
diff --git a/clang/test/ARCMT/cxx-checking.mm b/clang/test/ARCMT/cxx-checking.mm
deleted file mode 100644
index f8836d9d7cd8df..00000000000000
--- a/clang/test/ARCMT/cxx-checking.mm
+++ /dev/null
@@ -1,100 +0,0 @@
-// RUN: %clang_cc1 -arcmt-action=check -verify -triple x86_64-apple-darwin10 -fsyntax-only -fblocks %s
-
-// Classes that have an Objective-C object pointer.
-struct HasObjectMember0 {
- id x;
-};
-
-struct HasObjectMember1 {
- id x[3];
-};
-
-struct HasObjectMember2 {
- id x[3][2];
-};
-
-// Don't complain if the type has non-external linkage
-namespace {
- struct HasObjectMember3 {
- id x[3][2];
- };
-}
-
-// Don't complain if the Objective-C pointer type was explicitly given
-// no lifetime.
-struct HasObjectMember3 {
- __unsafe_unretained id x[3][2];
-};
-
-struct HasBlockPointerMember0 {
- int (^bp)(int);
-};
-
-struct HasBlockPointerMember1 {
- int (^bp[2][3])(int);
-};
-
-struct NonPOD {
- NonPOD(const NonPOD&);
-};
-
-struct HasObjectMemberAndNonPOD0 {
- id x;
- NonPOD np;
-};
-
-struct HasObjectMemberAndNonPOD1 {
- NonPOD np;
- id x[3];
-};
-
-struct HasObjectMemberAndNonPOD2 {
- NonPOD np;
- id x[3][2];
-};
-
-struct HasObjectMemberAndNonPOD3 {
- HasObjectMemberAndNonPOD3 &operator=(const HasObjectMemberAndNonPOD3&);
- ~HasObjectMemberAndNonPOD3();
- NonPOD np;
- id x[3][2];
-};
-
-struct HasBlockPointerMemberAndNonPOD0 {
- NonPOD np;
- int (^bp)(int);
-};
-
-struct HasBlockPointerMemberAndNonPOD1 {
- NonPOD np;
- int (^bp[2][3])(int);
-};
-
-int check_non_pod_objc_pointer0[__is_pod(id)? 1 : -1];
-int check_non_pod_objc_pointer1[__is_pod(__strong id)? -1 : 1];
-int check_non_pod_objc_pointer2[__is_pod(__unsafe_unretained id)? 1 : -1];
-int check_non_pod_objc_pointer3[__is_pod(id[2][3])? 1 : -1];
-int check_non_pod_objc_pointer4[__is_pod(__unsafe_unretained id[2][3])? 1 : -1];
-int check_non_pod_block0[__is_pod(int (^)(int))? 1 : -1];
-int check_non_pod_block1[__is_pod(int (^ __unsafe_unretained)(int))? 1 : -1];
-
-struct FlexibleArrayMember0 {
- int length;
- id array[]; // expected-error{{flexible array member 'array' of type '__strong id[]' with non-trivial destruction}}
-};
-
-struct FlexibleArrayMember1 {
- int length;
- __unsafe_unretained id array[];
-};
-
-// It's okay to pass a retainable type through an ellipsis.
-void variadic(...);
-void test_variadic() {
- variadic(1, 17, @"Foo");
-}
-
-// It's okay to create a VLA of retainable types.
-void vla(int n) {
- id vla[n];
-}
diff --git a/clang/test/ARCMT/cxx-rewrite.mm b/clang/test/ARCMT/cxx-rewrite.mm
deleted file mode 100644
index 4a9c50c92426e8..00000000000000
--- a/clang/test/ARCMT/cxx-rewrite.mm
+++ /dev/null
@@ -1,33 +0,0 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c++ %s.result
-// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c++ %s > %t
-// RUN: diff %t %s.result
-
-#include "Common.h"
-
- at interface NSString : NSObject
-+(id)string;
- at end
-
-struct foo {
- NSString *s;
- foo(NSString *s): s([s retain]){
- NSAutoreleasePool *pool = [NSAutoreleasePool new];
- [[[NSString string] retain] release];
- [pool drain];
- if (s)
- [s release];
- }
- ~foo(){ [s release]; }
-private:
- foo(foo const &);
- foo &operator=(foo const &);
-};
-
-int main(){
- NSAutoreleasePool *pool = [NSAutoreleasePool new];
-
- foo f([[NSString string] autorelease]);
-
- [pool drain];
- return 0;
-}
diff --git a/clang/test/ARCMT/cxx-rewrite.mm.result b/clang/test/ARCMT/cxx-rewrite.mm.result
deleted file mode 100644
index a96d254bf4633e..00000000000000
--- a/clang/test/ARCMT/cxx-rewrite.mm.result
+++ /dev/null
@@ -1,31 +0,0 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c++ %s.result
-// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c++ %s > %t
-// RUN: diff %t %s.result
-
-#include "Common.h"
-
- at interface NSString : NSObject
-+(id)string;
- at end
-
-struct foo {
- NSString *s;
- foo(NSString *s): s(s){
- @autoreleasepool {
- [NSString string];
- }
- }
- ~foo(){ }
-private:
- foo(foo const &);
- foo &operator=(foo const &);
-};
-
-int main(){
- @autoreleasepool {
-
- foo f([NSString string]);
-
- }
- return 0;
-}
diff --git a/clang/test/ARCMT/dealloc.m b/clang/test/ARCMT/dealloc.m
deleted file mode 100644
index d7a72af4f726fe..00000000000000
--- a/clang/test/ARCMT/dealloc.m
+++ /dev/null
@@ -1,24 +0,0 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result
-// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s > %t
-// RUN: diff %t %s.result
-
- at interface A
-- (id)retain;
-- (id)autorelease;
-- (oneway void)release;
-- (void)dealloc;
- at end
-
-void test1(A *a) {
- [a dealloc];
-}
-
- at interface Test2 : A
-- (void) dealloc;
- at end
-
- at implementation Test2
-- (void) dealloc {
- [super dealloc];
-}
- at end
diff --git a/clang/test/ARCMT/dealloc.m.result b/clang/test/ARCMT/dealloc.m.result
deleted file mode 100644
index fbd9e445d27512..00000000000000
--- a/clang/test/ARCMT/dealloc.m.result
+++ /dev/null
@@ -1,20 +0,0 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result
-// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s > %t
-// RUN: diff %t %s.result
-
- at interface A
-- (id)retain;
-- (id)autorelease;
-- (oneway void)release;
-- (void)dealloc;
- at end
-
-void test1(A *a) {
-}
-
- at interface Test2 : A
-- (void) dealloc;
- at end
-
- at implementation Test2
- at end
diff --git a/clang/test/ARCMT/designated-init-in-header/designated-init-in-header.m b/clang/test/ARCMT/designated-init-in-header/designated-init-in-header.m
deleted file mode 100644
index 8286583b3c898a..00000000000000
--- a/clang/test/ARCMT/designated-init-in-header/designated-init-in-header.m
+++ /dev/null
@@ -1,3 +0,0 @@
-// RUN: %clang_cc1 -objcmt-migrate-designated-init -objcmt-migrate-readwrite-property -objcmt-migrate-instancetype -x objective-c %S/file1.m.in -triple x86_64-apple-darwin11 -fobjc-arc -migrate -o %t1.remap
-// RUN: %clang_cc1 -objcmt-migrate-designated-init -objcmt-migrate-readwrite-property -objcmt-migrate-instancetype -x objective-c %S/file2.m.in -triple x86_64-apple-darwin11 -fobjc-arc -migrate -o %t2.remap
-// RUN: c-arcmt-test %t1.remap %t2.remap | arcmt-test -verify-transformed-files %S/header1.h.result %S/file2.m.in.result
diff --git a/clang/test/ARCMT/designated-init-in-header/file1.m.in b/clang/test/ARCMT/designated-init-in-header/file1.m.in
deleted file mode 100644
index 0201b32abd323d..00000000000000
--- a/clang/test/ARCMT/designated-init-in-header/file1.m.in
+++ /dev/null
@@ -1,2 +0,0 @@
-#include "header1.h"
-
diff --git a/clang/test/ARCMT/designated-init-in-header/file2.m.in b/clang/test/ARCMT/designated-init-in-header/file2.m.in
deleted file mode 100644
index 258159735a77f5..00000000000000
--- a/clang/test/ARCMT/designated-init-in-header/file2.m.in
+++ /dev/null
@@ -1,14 +0,0 @@
-#include "header1.h"
-
- at implementation S1
--(int)prop { return 0; }
--(void)setProp:(int)p {}
-+(id)s1 { return 0; }
--(id)initWithFoo:(NSString*)foo
-{
- self = [super init];
- if (self) {
- }
- return self;
-}
- at end
diff --git a/clang/test/ARCMT/designated-init-in-header/file2.m.in.result b/clang/test/ARCMT/designated-init-in-header/file2.m.in.result
deleted file mode 100644
index 7465ed576f5ff9..00000000000000
--- a/clang/test/ARCMT/designated-init-in-header/file2.m.in.result
+++ /dev/null
@@ -1,14 +0,0 @@
-#include "header1.h"
-
- at implementation S1
--(int)prop { return 0; }
--(void)setProp:(int)p {}
-+(instancetype)s1 { return 0; }
--(instancetype)initWithFoo:(NSString*)foo
-{
- self = [super init];
- if (self) {
- }
- return self;
-}
- at end
diff --git a/clang/test/ARCMT/designated-init-in-header/header1.h b/clang/test/ARCMT/designated-init-in-header/header1.h
deleted file mode 100644
index c5668cc460869c..00000000000000
--- a/clang/test/ARCMT/designated-init-in-header/header1.h
+++ /dev/null
@@ -1,14 +0,0 @@
-#define NS_DESIGNATED_INITIALIZER __attribute__((objc_designated_initializer))
-
- at class NSString;
-
- at interface B1
--(id)init;
- at end
-
- at interface S1 : B1
--(int)prop;
--(void)setProp:(int)p;
-+(id)s1;
--(id)initWithFoo:(NSString*)foo;
- at end
diff --git a/clang/test/ARCMT/designated-init-in-header/header1.h.result b/clang/test/ARCMT/designated-init-in-header/header1.h.result
deleted file mode 100644
index 974175b1c3e639..00000000000000
--- a/clang/test/ARCMT/designated-init-in-header/header1.h.result
+++ /dev/null
@@ -1,13 +0,0 @@
-#define NS_DESIGNATED_INITIALIZER __attribute__((objc_designated_initializer))
-
- at class NSString;
-
- at interface B1
--(instancetype)init;
- at end
-
- at interface S1 : B1
- at property (nonatomic) int prop;
-+(instancetype)s1;
--(instancetype)initWithFoo:(NSString*)foo NS_DESIGNATED_INITIALIZER;
- at end
diff --git a/clang/test/ARCMT/dispatch.m b/clang/test/ARCMT/dispatch.m
deleted file mode 100644
index 58c7769638cbe7..00000000000000
--- a/clang/test/ARCMT/dispatch.m
+++ /dev/null
@@ -1,18 +0,0 @@
-// RUN: %clang_cc1 -fblocks -fsyntax-only -fobjc-arc -x objective-c %s.result
-// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fblocks -fsyntax-only -x objective-c %s > %t
-// RUN: diff %t %s.result
-
-#include "Common.h"
-
-dispatch_object_t getme(void);
-
-void func(dispatch_object_t o) {
- dispatch_retain(o);
- dispatch_release(o);
- dispatch_retain(getme());
-}
-
-void func2(xpc_object_t o) {
- xpc_retain(o);
- xpc_release(o);
-}
diff --git a/clang/test/ARCMT/dispatch.m.result b/clang/test/ARCMT/dispatch.m.result
deleted file mode 100644
index 55b65585e4f6c2..00000000000000
--- a/clang/test/ARCMT/dispatch.m.result
+++ /dev/null
@@ -1,14 +0,0 @@
-// RUN: %clang_cc1 -fblocks -fsyntax-only -fobjc-arc -x objective-c %s.result
-// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fblocks -fsyntax-only -x objective-c %s > %t
-// RUN: diff %t %s.result
-
-#include "Common.h"
-
-dispatch_object_t getme(void);
-
-void func(dispatch_object_t o) {
- getme();
-}
-
-void func2(xpc_object_t o) {
-}
diff --git a/clang/test/ARCMT/driver-migrate.m b/clang/test/ARCMT/driver-migrate.m
deleted file mode 100644
index ec3f4cc8c4a312..00000000000000
--- a/clang/test/ARCMT/driver-migrate.m
+++ /dev/null
@@ -1,15 +0,0 @@
-// RUN: %clang -### -ccc-arcmt-migrate /foo/bar -fsyntax-only %s 2>&1 | FileCheck %s
-
-// CHECK: "-arcmt-action=migrate" "-mt-migrate-directory" "{{[^"]*}}/foo/bar"
-
-// RUN: touch %t.o
-// RUN: %clang -ccc-arcmt-check -target i386-apple-darwin9 -### %t.o 2> %t.log
-// RUN: FileCheck -check-prefix=LINK %s < %t.log
-// RUN: %clang -ccc-arcmt-migrate /foo/bar -target i386-apple-darwin9 -### %t.o 2> %t.log
-// RUN: FileCheck -check-prefix=LINK %s < %t.log
-
-// LINK-NOT: {{ld(.exe)?"}}
-// LINK: {{touch(.exe)?"}}
-
-// RUN: %clang -### -ccc-arcmt-migrate /foo/bar -fsyntax-only -fno-objc-arc %s 2>&1 | FileCheck -check-prefix=CHECK-NOARC %s
-// CHECK-NOARC-NOT: argument unused during compilation
diff --git a/clang/test/ARCMT/init.m b/clang/test/ARCMT/init.m
deleted file mode 100644
index b1f127e54fd1b4..00000000000000
--- a/clang/test/ARCMT/init.m
+++ /dev/null
@@ -1,39 +0,0 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result
-// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s > %t
-// RUN: diff %t %s.result
-
-#define nil (void *)0
-
- at interface NSObject
--init;
- at end
-
- at interface A : NSObject
--init;
--init2;
--foo;
-+alloc;
- at end
-
- at implementation A
--(id) init {
- [self init];
- id a;
- [a init];
- a = [[A alloc] init];
-
- return self;
-}
-
--(id) init2 {
- [super init];
- return self;
-}
-
--(id) foo {
- [self init];
- [super init];
-
- return self;
-}
- at end
diff --git a/clang/test/ARCMT/init.m.result b/clang/test/ARCMT/init.m.result
deleted file mode 100644
index d550dedb1dc191..00000000000000
--- a/clang/test/ARCMT/init.m.result
+++ /dev/null
@@ -1,39 +0,0 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result
-// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s > %t
-// RUN: diff %t %s.result
-
-#define nil (void *)0
-
- at interface NSObject
--init;
- at end
-
- at interface A : NSObject
--init;
--init2;
--foo;
-+alloc;
- at end
-
- at implementation A
--(id) init {
- if (!(self = [self init])) return nil;
- id a;
- [a init];
- a = [[A alloc] init];
-
- return self;
-}
-
--(id) init2 {
- if (!(self = [super init])) return nil;
- return self;
-}
-
--(id) foo {
- [self init];
- [super init];
-
- return self;
-}
- at end
diff --git a/clang/test/ARCMT/lit.local.cfg b/clang/test/ARCMT/lit.local.cfg
deleted file mode 100644
index e9b04164d69df8..00000000000000
--- a/clang/test/ARCMT/lit.local.cfg
+++ /dev/null
@@ -1,2 +0,0 @@
-if not config.root.clang_arcmt:
- config.unsupported = True
diff --git a/clang/test/ARCMT/migrate-emit-errors.m b/clang/test/ARCMT/migrate-emit-errors.m
deleted file mode 100644
index 3e33acf75a5914..00000000000000
--- a/clang/test/ARCMT/migrate-emit-errors.m
+++ /dev/null
@@ -1,12 +0,0 @@
-// RUN: %clang_cc1 -arcmt-action=migrate -mt-migrate-directory %t -arcmt-migrate-emit-errors %s 2>&1 | FileCheck %s
-// RUN: rm -rf %t
-
- at protocol NSObject
-- (oneway void)release;
- at end
-
-void test(id p) {
- [p release];
-}
-
-// CHECK: error: ARC forbids explicit message send of 'release'
diff --git a/clang/test/ARCMT/migrate-on-pch-and-module.m b/clang/test/ARCMT/migrate-on-pch-and-module.m
deleted file mode 100644
index 42e01ea91a9c72..00000000000000
--- a/clang/test/ARCMT/migrate-on-pch-and-module.m
+++ /dev/null
@@ -1,12 +0,0 @@
-// RUN: rm -rf %t-mcp
-// RUN: %clang_cc1 -objcmt-migrate-subscripting -emit-pch -o %t.pch %s -isysroot %S/Inputs/System -triple x86_64-apple-darwin10 -F %S/Inputs -fmodules -fimplicit-module-maps -fmodules-cache-path=%t-mcp -w
-// RUN: %clang_cc1 -objcmt-migrate-subscripting -include-pch %t.pch %s -migrate -o %t.remap -isysroot %S/Inputs/System -triple x86_64-apple-darwin10 -F %S/Inputs -fmodules -fimplicit-module-maps -fmodules-cache-path=%t-mcp
-// REQUIRES: x86-registered-target
-#ifndef HEADER
-#define HEADER
-
- at import Module;
-
-#else
-
-#endif
diff --git a/clang/test/ARCMT/migrate-plist-output.m b/clang/test/ARCMT/migrate-plist-output.m
deleted file mode 100644
index e5710d818eccc6..00000000000000
--- a/clang/test/ARCMT/migrate-plist-output.m
+++ /dev/null
@@ -1,51 +0,0 @@
-// RUN: %clang_cc1 -arcmt-action=migrate -mt-migrate-directory %t.dir -arcmt-migrate-report-output %t.plist %s
-// RUN: FileCheck %s -input-file=%t.plist
-// RUN: rm -rf %t.dir
-
- at protocol NSObject
-- (oneway void)release;
- at end
-
-void test(id p) {
- [p release];
-}
-
-// CHECK: <?xml version="1.0" encoding="UTF-8"?>
-// CHECK: <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-// CHECK: <plist version="1.0">
-// CHECK: <dict>
-// CHECK: <key>files</key>
-// CHECK: <array>
-// CHECK: </array>
-// CHECK: <key>diagnostics</key>
-// CHECK: <array>
-// CHECK: <dict>
-// CHECK: <key>description</key><string>ARC forbids explicit message send of 'release'</string>
-// CHECK: <key>category</key><string>ARC Restrictions</string>
-// CHECK: <key>type</key><string>error</string>
-// CHECK: <key>location</key>
-// CHECK: <dict>
-// CHECK: <key>line</key><integer>10</integer>
-// CHECK: <key>col</key><integer>6</integer>
-// CHECK: <key>file</key><integer>0</integer>
-// CHECK: </dict>
-// CHECK: <key>ranges</key>
-// CHECK: <array>
-// CHECK: <array>
-// CHECK: <dict>
-// CHECK: <key>line</key><integer>10</integer>
-// CHECK: <key>col</key><integer>4</integer>
-// CHECK: <key>file</key><integer>0</integer>
-// CHECK: </dict>
-// CHECK: <dict>
-// CHECK: <key>line</key><integer>10</integer>
-// CHECK: <key>col</key><integer>4</integer>
-// CHECK: <key>file</key><integer>0</integer>
-// CHECK: </dict>
-// CHECK: </array>
-// CHECK: </array>
-// CHECK: </dict>
-// CHECK: </array>
-// CHECK: </dict>
-// CHECK: </plist>
-
diff --git a/clang/test/ARCMT/migrate-space-in-path.m b/clang/test/ARCMT/migrate-space-in-path.m
deleted file mode 100644
index 14a464d438f40d..00000000000000
--- a/clang/test/ARCMT/migrate-space-in-path.m
+++ /dev/null
@@ -1,5 +0,0 @@
-// RUN: rm -rf %t.migrate
-// RUN: %clang_cc1 -arcmt-action=migrate -mt-migrate-directory %t.migrate %S/Inputs/"with space"/test1.m.in -x objective-c
-// RUN: %clang_cc1 -arcmt-action=migrate -mt-migrate-directory %t.migrate %S/Inputs/"with space"/test2.m.in -x objective-c
-// RUN: c-arcmt-test -mt-migrate-directory %t.migrate | arcmt-test -verify-transformed-files %S/Inputs/"with space"/test1.m.in.result %S/Inputs/"with space"/test2.m.in.result %S/Inputs/"with space"/test.h.result
-// RUN: rm -rf %t.migrate
diff --git a/clang/test/ARCMT/migrate-with-pch.m b/clang/test/ARCMT/migrate-with-pch.m
deleted file mode 100644
index d8e261be13d855..00000000000000
--- a/clang/test/ARCMT/migrate-with-pch.m
+++ /dev/null
@@ -1,6 +0,0 @@
-// RUN: rm -rf %t
-// RUN: %clang_cc1 -x objective-c %S/Common.h -emit-pch -o %t.pch
-// RUN: %clang_cc1 -arcmt-action=migrate -mt-migrate-directory %t %S/Inputs/test1.m.in -x objective-c -include-pch %t.pch
-// RUN: %clang_cc1 -arcmt-action=migrate -mt-migrate-directory %t %S/Inputs/test2.m.in -x objective-c -include-pch %t.pch
-// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %S/Inputs/test1.m.in.result %S/Inputs/test2.m.in.result %S/Inputs/test.h.result
-// RUN: rm -rf %t
diff --git a/clang/test/ARCMT/migrate.m b/clang/test/ARCMT/migrate.m
deleted file mode 100644
index bc819df1c8a110..00000000000000
--- a/clang/test/ARCMT/migrate.m
+++ /dev/null
@@ -1,5 +0,0 @@
-// RUN: rm -rf %t
-// RUN: %clang_cc1 -arcmt-action=migrate -mt-migrate-directory %t %S/Inputs/test1.m.in -x objective-c
-// RUN: %clang_cc1 -arcmt-action=migrate -mt-migrate-directory %t %S/Inputs/test2.m.in -x objective-c
-// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %S/Inputs/test1.m.in.result %S/Inputs/test2.m.in.result %S/Inputs/test.h.result
-// RUN: rm -rf %t
diff --git a/clang/test/ARCMT/no-canceling-bridge-to-bridge-cast.m b/clang/test/ARCMT/no-canceling-bridge-to-bridge-cast.m
deleted file mode 100644
index be493949515233..00000000000000
--- a/clang/test/ARCMT/no-canceling-bridge-to-bridge-cast.m
+++ /dev/null
@@ -1,41 +0,0 @@
-// RUN: %clang_cc1 -arcmt-action=check -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c -verify %s
-typedef const void * CFTypeRef;
-CFTypeRef CFBridgingRetain(id X);
-id CFBridgingRelease(CFTypeRef);
-
-extern
-CFTypeRef CFRetain(CFTypeRef cf);
-
- at interface INTF
-{
- void *cf_format;
- id objc_format;
-}
- at end
-
- at interface NSString
-+ (id)stringWithFormat:(NSString *)format;
- at end
-
- at implementation INTF
-- (void) Meth {
- NSString *result;
-
- result = (id) CFRetain([NSString stringWithFormat:@"PBXLoopMode"]); // expected-error {{cast of C pointer type 'CFTypeRef' (aka 'const void *') to Objective-C pointer type 'id' requires a bridged cast}} \
- // expected-note {{use __bridge to convert directly (no change in ownership)}} \
- // expected-note {{use CFBridgingRelease call to transfer ownership of a +1 'CFTypeRef' (aka 'const void *') into ARC}}
-
- result = (id) CFRetain((id)((objc_format))); // expected-error {{cast of C pointer type 'CFTypeRef' (aka 'const void *') to Objective-C pointer type 'id' requires a bridged cast}} \
- // expected-note {{use __bridge to convert directly (no change in ownership)}} \
- // expected-note {{use CFBridgingRelease call to transfer ownership of a +1 'CFTypeRef' (aka 'const void *') into ARC}}
-
- result = (id) CFRetain((id)((cf_format))); // expected-error {{cast of C pointer type 'CFTypeRef' (aka 'const void *') to Objective-C pointer type 'id' requires a bridged cast}} \
- // expected-note {{use __bridge to convert directly (no change in ownership)}} \
- // expected-note {{use CFBridgingRelease call to transfer ownership of a +1 'CFTypeRef' (aka 'const void *') into ARC}}
-
- result = (id) CFRetain((CFTypeRef)((objc_format)));
-
- result = (id) CFRetain(cf_format); // OK
-}
- at end
-
diff --git a/clang/test/ARCMT/nonobjc-to-objc-cast-2.m b/clang/test/ARCMT/nonobjc-to-objc-cast-2.m
deleted file mode 100644
index 391c636906d53e..00000000000000
--- a/clang/test/ARCMT/nonobjc-to-objc-cast-2.m
+++ /dev/null
@@ -1,63 +0,0 @@
-// RUN: %clang_cc1 -arcmt-action=check -verify -triple x86_64-apple-darwin10 %s
-
-#include "Common.h"
-
-typedef const struct __CFString * CFStringRef;
-typedef const void * CFTypeRef;
-CFTypeRef CFBridgingRetain(id X);
-id CFBridgingRelease(CFTypeRef);
-
-struct StrS {
- CFStringRef sref_member;
-};
-
- at interface NSString : NSObject {
- CFStringRef sref;
- struct StrS *strS;
-}
--(id)string;
--(id)newString;
- at end
-
- at implementation NSString
--(id)string {
- if (0)
- return sref;
- else
- return strS->sref_member;
-}
--(id)newString {
- return sref; // expected-error {{implicit conversion of C pointer type 'CFStringRef' (aka 'const struct __CFString *') to Objective-C pointer type 'id' requires a bridged cast}} \
- // expected-note{{use __bridge to convert directly (no change in ownership)}} \
- // expected-note{{use CFBridgingRelease call to transfer ownership of a +1 'CFStringRef' (aka 'const struct __CFString *') into ARC}}
-}
- at end
-
-void f(BOOL b) {
- CFStringRef cfstr;
- NSString *str = (NSString *)cfstr; // expected-error {{cast of C pointer type 'CFStringRef' (aka 'const struct __CFString *') to Objective-C pointer type 'NSString *' requires a bridged cast}} \
- // expected-note{{use __bridge to convert directly (no change in ownership)}} \
- // expected-note{{use CFBridgingRelease call to transfer ownership of a +1 'CFStringRef' (aka 'const struct __CFString *') into ARC}}
- void *vp = str; // expected-error {{requires a bridged cast}} expected-note {{use CFBridgingRetain call}} expected-note {{use __bridge}}
-}
-
-void f2(NSString *s) {
- CFStringRef ref;
- ref = [(CFStringRef)[s string] retain]; // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef' (aka 'const struct __CFString *') requires a bridged cast}} \
- // expected-error {{bad receiver type 'CFStringRef' (aka 'const struct __CFString *')}} \
- // expected-note{{use __bridge to convert directly (no change in ownership)}} \
- // expected-note{{use CFBridgingRetain call to make an ARC object available as a +1 'CFStringRef' (aka 'const struct __CFString *')}}
-}
-
-CFStringRef f3(void) {
- return (CFStringRef)[[[NSString alloc] init] autorelease]; // expected-error {{it is not safe to cast to 'CFStringRef' the result of 'autorelease' message; a __bridge cast may result in a pointer to a destroyed object and a __bridge_retained may leak the object}} \
- // expected-note {{remove the cast and change return type of function to 'NSString *' to have the object automatically autoreleased}}
-}
-
-extern void NSLog(NSString *format, ...);
-
-void f4(NSString *s) {
- NSLog(@"%@", (CFStringRef)s); // expected-error {{cast of Objective-C pointer type 'NSString *' to C pointer type 'CFStringRef' (aka 'const struct __CFString *') requires a bridged cast}} \
- // expected-note{{use __bridge to convert directly (no change in ownership)}} \
- // expected-note{{use CFBridgingRetain call to make an ARC object available as a +1 'CFStringRef' (aka 'const struct __CFString *')}}
-}
diff --git a/clang/test/ARCMT/nonobjc-to-objc-cast.m b/clang/test/ARCMT/nonobjc-to-objc-cast.m
deleted file mode 100644
index 7913661787e509..00000000000000
--- a/clang/test/ARCMT/nonobjc-to-objc-cast.m
+++ /dev/null
@@ -1,83 +0,0 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result
-// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s > %t
-// RUN: diff %t %s.result
-
-#include "Common.h"
-
-typedef const struct __CFString * CFStringRef;
-extern const CFStringRef kUTTypePlainText;
-extern const CFStringRef kUTTypeRTF;
-extern CFStringRef kNonConst;
-
-typedef const struct __CFAllocator * CFAllocatorRef;
-typedef const struct __CFUUID * CFUUIDRef;
-
-extern const CFAllocatorRef kCFAllocatorDefault;
-
-extern CFStringRef CFUUIDCreateString(CFAllocatorRef alloc, CFUUIDRef uuid);
-
-struct StrS {
- CFStringRef sref_member;
-};
-
- at interface NSString : NSObject {
- CFStringRef sref;
- struct StrS *strS;
-}
--(id)string;
--(id)newString;
- at end
-
-void f(BOOL b, id p) {
- NSString *str = (NSString *)kUTTypePlainText; // no change
- str = b ? kUTTypeRTF : kUTTypePlainText; // no change
- str = (NSString *)(b ? kUTTypeRTF : kUTTypePlainText); // no change
- str = (NSString *)p; // no change.
-
- str = (NSString *)kNonConst;
- str = b ? kUTTypeRTF : kNonConst;
- str = (NSString *)(b ? kUTTypeRTF : kNonConst);
-
- CFUUIDRef _uuid;
- NSString *_uuidString = (NSString *)CFUUIDCreateString(kCFAllocatorDefault, _uuid);
- _uuidString = [(NSString *)CFUUIDCreateString(kCFAllocatorDefault, _uuid) autorelease];
- _uuidString = CFRetain(_uuid);
-}
-
- at implementation NSString (StrExt)
-- (NSString *)stringEscapedAsURI {
- CFStringRef str = (CFStringRef)self;
- CFStringRef str2 = self;
- return self;
-}
- at end
-
- at implementation NSString
--(id)string {
- if (0)
- return sref;
- else
- return strS->sref_member;
-}
--(id)newString { return 0; }
- at end
-
-extern void consumeParam(CFStringRef CF_CONSUMED p);
-
-void f2(NSString *s) {
- CFStringRef ref = [s string];
- ref = (CFStringRef)[s string];
- ref = s.string;
- ref = [NSString new];
- ref = [s newString];
- ref = (CFStringRef)[NSString new];
- ref = [[NSString alloc] init];
- ref = [[s string] retain];
- ref = CFRetain((CFStringRef)[s string]);
- ref = CFRetain([s string]);
- ref = CFRetain(s);
- ref = [s retain];
-
- consumeParam((CFStringRef)s);
- consumeParam(s);
-}
diff --git a/clang/test/ARCMT/nonobjc-to-objc-cast.m.result b/clang/test/ARCMT/nonobjc-to-objc-cast.m.result
deleted file mode 100644
index 8f3092f8786d8b..00000000000000
--- a/clang/test/ARCMT/nonobjc-to-objc-cast.m.result
+++ /dev/null
@@ -1,83 +0,0 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result
-// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s > %t
-// RUN: diff %t %s.result
-
-#include "Common.h"
-
-typedef const struct __CFString * CFStringRef;
-extern const CFStringRef kUTTypePlainText;
-extern const CFStringRef kUTTypeRTF;
-extern CFStringRef kNonConst;
-
-typedef const struct __CFAllocator * CFAllocatorRef;
-typedef const struct __CFUUID * CFUUIDRef;
-
-extern const CFAllocatorRef kCFAllocatorDefault;
-
-extern CFStringRef CFUUIDCreateString(CFAllocatorRef alloc, CFUUIDRef uuid);
-
-struct StrS {
- CFStringRef sref_member;
-};
-
- at interface NSString : NSObject {
- CFStringRef sref;
- struct StrS *strS;
-}
--(id)string;
--(id)newString;
- at end
-
-void f(BOOL b, id p) {
- NSString *str = (NSString *)kUTTypePlainText; // no change
- str = b ? kUTTypeRTF : kUTTypePlainText; // no change
- str = (NSString *)(b ? kUTTypeRTF : kUTTypePlainText); // no change
- str = (NSString *)p; // no change.
-
- str = (__bridge NSString *)kNonConst;
- str = (__bridge NSString *)(b ? kUTTypeRTF : kNonConst);
- str = (__bridge NSString *)(b ? kUTTypeRTF : kNonConst);
-
- CFUUIDRef _uuid;
- NSString *_uuidString = (NSString *)CFBridgingRelease(CFUUIDCreateString(kCFAllocatorDefault, _uuid));
- _uuidString = (NSString *)CFBridgingRelease(CFUUIDCreateString(kCFAllocatorDefault, _uuid));
- _uuidString = CFBridgingRelease(CFRetain(_uuid));
-}
-
- at implementation NSString (StrExt)
-- (NSString *)stringEscapedAsURI {
- CFStringRef str = (__bridge CFStringRef)self;
- CFStringRef str2 = (__bridge CFStringRef)(self);
- return self;
-}
- at end
-
- at implementation NSString
--(id)string {
- if (0)
- return (__bridge id)(sref);
- else
- return (__bridge id)(strS->sref_member);
-}
--(id)newString { return 0; }
- at end
-
-extern void consumeParam(CFStringRef CF_CONSUMED p);
-
-void f2(NSString *s) {
- CFStringRef ref = (__bridge CFStringRef)([s string]);
- ref = (__bridge CFStringRef)[s string];
- ref = (__bridge CFStringRef)(s.string);
- ref = CFBridgingRetain([NSString new]);
- ref = CFBridgingRetain([s newString]);
- ref = (CFStringRef)CFBridgingRetain([NSString new]);
- ref = CFBridgingRetain([[NSString alloc] init]);
- ref = CFBridgingRetain([s string]);
- ref = (CFStringRef)CFBridgingRetain([s string]);
- ref = CFBridgingRetain([s string]);
- ref = CFBridgingRetain(s);
- ref = CFBridgingRetain(s);
-
- consumeParam((CFStringRef)CFBridgingRetain(s));
- consumeParam(CFBridgingRetain(s));
-}
diff --git a/clang/test/ARCMT/objcmt-arc-cf-annotations.m b/clang/test/ARCMT/objcmt-arc-cf-annotations.m
deleted file mode 100644
index 47c83ac9e3dd55..00000000000000
--- a/clang/test/ARCMT/objcmt-arc-cf-annotations.m
+++ /dev/null
@@ -1,2017 +0,0 @@
-// RUN: rm -rf %t
-// RUN: %clang_cc1 -fblocks -objcmt-migrate-annotation -objcmt-migrate-instancetype -objcmt-migrate-readwrite-property -mt-migrate-directory %t %s -x objective-c -triple x86_64-apple-darwin11
-// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result
-// RUN: %clang_cc1 -fblocks -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s.result
-
-#ifndef CF_IMPLICIT_BRIDGING_ENABLED
-#if __has_feature(arc_cf_code_audited)
-#define CF_IMPLICIT_BRIDGING_ENABLED _Pragma("clang arc_cf_code_audited begin")
-#else
-#define CF_IMPLICIT_BRIDGING_ENABLED
-#endif
-#endif
-
-#ifndef CF_IMPLICIT_BRIDGING_DISABLED
-#if __has_feature(arc_cf_code_audited)
-#define CF_IMPLICIT_BRIDGING_DISABLED _Pragma("clang arc_cf_code_audited end")
-#else
-#define CF_IMPLICIT_BRIDGING_DISABLED
-#endif
-#endif
-
-#if __has_feature(attribute_ns_returns_retained)
-#define NS_RETURNS_RETAINED __attribute__((ns_returns_retained))
-#endif
-#if __has_feature(attribute_cf_returns_retained)
-#define CF_RETURNS_RETAINED __attribute__((cf_returns_retained))
-#endif
-#if __has_feature(attribute_ns_returns_not_retained)
-#define NS_RETURNS_NOT_RETAINED __attribute__((ns_returns_not_retained))
-#endif
-#if __has_feature(attribute_cf_returns_not_retained)
-#define CF_RETURNS_NOT_RETAINED __attribute__((cf_returns_not_retained))
-#endif
-#if __has_feature(attribute_ns_consumes_self)
-#define NS_CONSUMES_SELF __attribute__((ns_consumes_self))
-#endif
-#if __has_feature(attribute_ns_consumed)
-#define NS_CONSUMED __attribute__((ns_consumed))
-#endif
-#if __has_feature(attribute_cf_consumed)
-#define CF_CONSUMED __attribute__((cf_consumed))
-#endif
-#if __has_attribute(ns_returns_autoreleased)
-#define NS_RETURNS_AUTORELEASED __attribute__((ns_returns_autoreleased))
-#endif
-
-//===----------------------------------------------------------------------===//
-// The following code is reduced using delta-debugging from Mac OS X headers:
-//
-// #include <Cocoa/Cocoa.h>
-// #include <CoreFoundation/CoreFoundation.h>
-// #include <DiskArbitration/DiskArbitration.h>
-// #include <QuartzCore/QuartzCore.h>
-// #include <Quartz/Quartz.h>
-// #include <IOKit/IOKitLib.h>
-//
-// It includes the basic definitions for the test cases below.
-//===----------------------------------------------------------------------===//
-
-typedef unsigned int __darwin_natural_t;
-typedef unsigned long uintptr_t;
-typedef unsigned int uint32_t;
-typedef unsigned long long uint64_t;
-typedef unsigned int UInt32;
-typedef signed long CFIndex;
-typedef CFIndex CFByteOrder;
-typedef struct {
- CFIndex location;
- CFIndex length;
-} CFRange;
-static __inline__ __attribute__((always_inline)) CFRange CFRangeMake(CFIndex loc, CFIndex len) {
- CFRange range;
- range.location = loc;
- range.length = len;
- return range;
-}
-typedef const void * CFTypeRef;
-typedef const struct __CFString * CFStringRef;
-typedef const struct __CFAllocator * CFAllocatorRef;
-extern const CFAllocatorRef kCFAllocatorDefault;
-extern CFTypeRef CFRetain(CFTypeRef cf);
-extern void CFRelease(CFTypeRef cf);
-extern CFTypeRef CFAutorelease(CFTypeRef cf);
-extern CFTypeRef CFMakeCollectable(CFTypeRef cf);
-typedef struct {
-}
-CFArrayCallBacks;
-extern const CFArrayCallBacks kCFTypeArrayCallBacks;
-typedef const struct __CFArray * CFArrayRef;
-typedef struct __CFArray * CFMutableArrayRef;
-extern CFMutableArrayRef CFArrayCreateMutable(CFAllocatorRef allocator, CFIndex capacity, const CFArrayCallBacks *callBacks);
-extern const void *CFArrayGetValueAtIndex(CFArrayRef theArray, CFIndex idx);
-extern void CFArrayAppendValue(CFMutableArrayRef theArray, const void *value);
-typedef struct {
-}
-CFDictionaryKeyCallBacks;
-extern const CFDictionaryKeyCallBacks kCFTypeDictionaryKeyCallBacks;
-typedef struct {
-}
-CFDictionaryValueCallBacks;
-extern const CFDictionaryValueCallBacks kCFTypeDictionaryValueCallBacks;
-typedef const struct __CFDictionary * CFDictionaryRef;
-typedef struct __CFDictionary * CFMutableDictionaryRef;
-extern CFMutableDictionaryRef CFDictionaryCreateMutable(CFAllocatorRef allocator, CFIndex capacity, const CFDictionaryKeyCallBacks *keyCallBacks, const CFDictionaryValueCallBacks *valueCallBacks);
-typedef UInt32 CFStringEncoding;
-enum {
-kCFStringEncodingMacRoman = 0, kCFStringEncodingWindowsLatin1 = 0x0500, kCFStringEncodingISOLatin1 = 0x0201, kCFStringEncodingNextStepLatin = 0x0B01, kCFStringEncodingASCII = 0x0600, kCFStringEncodingUnicode = 0x0100, kCFStringEncodingUTF8 = 0x08000100, kCFStringEncodingNonLossyASCII = 0x0BFF , kCFStringEncodingUTF16 = 0x0100, kCFStringEncodingUTF16BE = 0x10000100, kCFStringEncodingUTF16LE = 0x14000100, kCFStringEncodingUTF32 = 0x0c000100, kCFStringEncodingUTF32BE = 0x18000100, kCFStringEncodingUTF32LE = 0x1c000100 };
-extern CFStringRef CFStringCreateWithCString(CFAllocatorRef alloc, const char *cStr, CFStringEncoding encoding);
-typedef double CFTimeInterval;
-typedef CFTimeInterval CFAbsoluteTime;
-extern CFAbsoluteTime CFAbsoluteTimeGetCurrent(void);
-typedef const struct __CFDate * CFDateRef;
-extern CFDateRef CFDateCreate(CFAllocatorRef allocator, CFAbsoluteTime at);
-extern CFAbsoluteTime CFDateGetAbsoluteTime(CFDateRef theDate);
-typedef __darwin_natural_t natural_t;
-typedef natural_t mach_port_name_t;
-typedef mach_port_name_t mach_port_t;
-typedef int kern_return_t;
-typedef kern_return_t mach_error_t;
-enum {
-kCFNumberSInt8Type = 1, kCFNumberSInt16Type = 2, kCFNumberSInt32Type = 3, kCFNumberSInt64Type = 4, kCFNumberFloat32Type = 5, kCFNumberFloat64Type = 6, kCFNumberCharType = 7, kCFNumberShortType = 8, kCFNumberIntType = 9, kCFNumberLongType = 10, kCFNumberLongLongType = 11, kCFNumberFloatType = 12, kCFNumberDoubleType = 13, kCFNumberCFIndexType = 14, kCFNumberNSIntegerType = 15, kCFNumberCGFloatType = 16, kCFNumberMaxType = 16 };
-typedef CFIndex CFNumberType;
-typedef const struct __CFNumber * CFNumberRef;
-extern CFNumberRef CFNumberCreate(CFAllocatorRef allocator, CFNumberType theType, const void *valuePtr);
-typedef const struct __CFAttributedString *CFAttributedStringRef;
-typedef struct __CFAttributedString *CFMutableAttributedStringRef;
-extern CFAttributedStringRef CFAttributedStringCreate(CFAllocatorRef alloc, CFStringRef str, CFDictionaryRef attributes) ;
-extern CFMutableAttributedStringRef CFAttributedStringCreateMutableCopy(CFAllocatorRef alloc, CFIndex maxLength, CFAttributedStringRef aStr) ;
-extern void CFAttributedStringSetAttribute(CFMutableAttributedStringRef aStr, CFRange range, CFStringRef attrName, CFTypeRef value) ;
-typedef signed char BOOL;
-typedef unsigned long NSUInteger;
- at class NSString, Protocol;
-extern void NSLog(NSString *format, ...) __attribute__((format(__NSString__, 1, 2)));
-typedef struct _NSZone NSZone;
- at class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
- at protocol NSObject
-- (BOOL)isEqual:(id)object;
-- (id)retain;
-- (oneway void)release;
-- (id)autorelease;
-- (NSString *)description;
-- (id)init;
- at end
- at protocol NSCopying
-- (id)copyWithZone:(NSZone *)zone;
- at end
- at protocol NSMutableCopying - (id)mutableCopyWithZone:(NSZone *)zone;
- at end
- at protocol NSCoding - (void)encodeWithCoder:(NSCoder *)aCoder;
- at end
- at interface NSObject <NSObject> {}
-+ (id)allocWithZone:(NSZone *)zone;
-+ (id)alloc;
-+ (id)new;
-- (void)dealloc;
- at end
- at interface NSObject (NSCoderMethods)
-- (id)awakeAfterUsingCoder:(NSCoder *)aDecoder;
- at end
-extern id NSAllocateObject(Class aClass, NSUInteger extraBytes, NSZone *zone);
-typedef struct {
-}
-NSFastEnumerationState;
- at protocol NSFastEnumeration
-- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id *)stackbuf count:(NSUInteger)len;
- at end
- at class NSString, NSDictionary;
- at interface NSValue : NSObject <NSCopying, NSCoding> - (void)getValue:(void *)value;
- at end
- at interface NSNumber : NSValue
-- (char)charValue;
-- (id)initWithInt:(int)value;
-+ (NSNumber *)numberWithInt:(int)value;
- at end
- at class NSString;
- at interface NSArray : NSObject <NSCopying, NSMutableCopying, NSCoding, NSFastEnumeration>
-- (NSUInteger)count;
-- (id)initWithObjects:(const id [])objects count:(NSUInteger)cnt;
-+ (id)arrayWithObject:(id)anObject;
-+ (id)arrayWithObjects:(const id [])objects count:(NSUInteger)cnt;
-+ (id)arrayWithObjects:(id)firstObj, ... __attribute__((sentinel(0,1)));
-- (id)initWithObjects:(id)firstObj, ... __attribute__((sentinel(0,1)));
-- (id)initWithArray:(NSArray *)array;
- at end @interface NSArray (NSArrayCreation) + (id)array;
- at end @interface NSAutoreleasePool : NSObject {
-}
-- (void)drain;
- at end extern NSString * const NSBundleDidLoadNotification;
-typedef double NSTimeInterval;
- at interface NSDate : NSObject <NSCopying, NSCoding> - (NSTimeInterval)timeIntervalSinceReferenceDate;
- at end typedef unsigned short unichar;
- at interface NSString : NSObject <NSCopying, NSMutableCopying, NSCoding>
-- (NSUInteger)length;
-- (NSString *)stringByAppendingString:(NSString *)aString;
-- ( const char *)UTF8String;
-- (id)initWithUTF8String:(const char *)nullTerminatedCString;
-+ (id)stringWithUTF8String:(const char *)nullTerminatedCString;
- at end @class NSString, NSURL, NSError;
- at interface NSData : NSObject <NSCopying, NSMutableCopying, NSCoding> - (NSUInteger)length;
-+ (id)dataWithBytesNoCopy:(void *)bytes length:(NSUInteger)length;
-+ (id)dataWithBytesNoCopy:(void *)bytes length:(NSUInteger)length freeWhenDone:(BOOL)b;
- at end @class NSLocale, NSDate, NSCalendar, NSTimeZone, NSError, NSArray, NSMutableDictionary;
- at interface NSDictionary : NSObject <NSCopying, NSMutableCopying, NSCoding, NSFastEnumeration>
-- (NSUInteger)count;
-+ (id)dictionaryWithObjects:(NSArray *)objects forKeys:(NSArray *)keys;
-+ (id)dictionaryWithObjects:(const id [])objects forKeys:(const id <NSCopying> [])keys count:(NSUInteger)cnt;
- at end
- at interface NSMutableDictionary : NSDictionary - (void)removeObjectForKey:(id)aKey;
-- (void)setObject:(id)anObject forKey:(id)aKey;
- at end @interface NSMutableDictionary (NSMutableDictionaryCreation) + (id)dictionaryWithCapacity:(NSUInteger)numItems;
- at end typedef double CGFloat;
-struct CGSize {
-};
-typedef struct CGSize CGSize;
-struct CGRect {
-};
-typedef struct CGRect CGRect;
-typedef mach_port_t io_object_t;
-typedef char io_name_t[128];
-typedef io_object_t io_iterator_t;
-typedef io_object_t io_service_t;
-typedef struct IONotificationPort * IONotificationPortRef;
-typedef void (*IOServiceMatchingCallback)( void * refcon, io_iterator_t iterator );
-io_service_t IOServiceGetMatchingService( mach_port_t mainPort, CFDictionaryRef matching );
-kern_return_t IOServiceGetMatchingServices( mach_port_t mainPort, CFDictionaryRef matching, io_iterator_t * existing );
-kern_return_t IOServiceAddNotification( mach_port_t mainPort, const io_name_t notificationType, CFDictionaryRef matching, mach_port_t wakePort, uintptr_t reference, io_iterator_t * notification ) __attribute__((deprecated)); // expected-note {{'IOServiceAddNotification' declared here}}
-kern_return_t IOServiceAddMatchingNotification( IONotificationPortRef notifyPort, const io_name_t notificationType, CFDictionaryRef matching, IOServiceMatchingCallback callback, void * refCon, io_iterator_t * notification );
-CFMutableDictionaryRef IOServiceMatching( const char * name );
-CFMutableDictionaryRef IOServiceNameMatching( const char * name );
-CFMutableDictionaryRef IOBSDNameMatching( mach_port_t mainPort, uint32_t options, const char * bsdName );
-CFMutableDictionaryRef IOOpenFirmwarePathMatching( mach_port_t mainPort, uint32_t options, const char * path );
-CFMutableDictionaryRef IORegistryEntryIDMatching( uint64_t entryID );
-typedef struct __DASession * DASessionRef;
-extern DASessionRef DASessionCreate( CFAllocatorRef allocator );
-typedef struct __DADisk * DADiskRef;
-extern DADiskRef DADiskCreateFromBSDName( CFAllocatorRef allocator, DASessionRef session, const char * name );
-extern DADiskRef DADiskCreateFromIOMedia( CFAllocatorRef allocator, DASessionRef session, io_service_t media );
-extern CFDictionaryRef DADiskCopyDescription( DADiskRef disk );
-extern DADiskRef DADiskCopyWholeDisk( DADiskRef disk );
- at interface NSTask : NSObject - (id)init;
- at end typedef struct CGColorSpace *CGColorSpaceRef;
-typedef struct CGImage *CGImageRef;
-typedef struct CGLayer *CGLayerRef;
- at interface NSResponder : NSObject <NSCoding> {
-}
- at end @protocol NSAnimatablePropertyContainer - (id)animator;
- at end extern NSString *NSAnimationTriggerOrderIn ;
- at interface NSView : NSResponder <NSAnimatablePropertyContainer> {
-}
- at end @protocol NSValidatedUserInterfaceItem - (SEL)action;
- at end @protocol NSUserInterfaceValidations - (BOOL)validateUserInterfaceItem:(id <NSValidatedUserInterfaceItem>)anItem;
- at end @class NSDate, NSDictionary, NSError, NSException, NSNotification;
- at class NSTextField, NSPanel, NSArray, NSWindow, NSImage, NSButton, NSError;
- at interface NSApplication : NSResponder <NSUserInterfaceValidations> {
-}
-- (void)beginSheet:(NSWindow *)sheet modalForWindow:(NSWindow *)docWindow modalDelegate:(id)modalDelegate didEndSelector:(SEL)didEndSelector contextInfo:(void *)contextInfo;
- at end enum {
-NSTerminateCancel = 0, NSTerminateNow = 1, NSTerminateLater = 2 };
-typedef NSUInteger NSApplicationTerminateReply;
- at protocol NSApplicationDelegate <NSObject> @optional - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender;
- at end @class NSAttributedString, NSEvent, NSFont, NSFormatter, NSImage, NSMenu, NSText, NSView, NSTextView;
- at interface NSCell : NSObject <NSCopying, NSCoding> {
-}
- at end
-typedef struct {
-}
-CVTimeStamp;
- at interface CIImage : NSObject <NSCoding, NSCopying> {
-}
-typedef int CIFormat;
- at end enum {
-kDAReturnSuccess = 0, kDAReturnError = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x01, kDAReturnBusy = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x02, kDAReturnBadArgument = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x03, kDAReturnExclusiveAccess = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x04, kDAReturnNoResources = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x05, kDAReturnNotFound = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x06, kDAReturnNotMounted = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x07, kDAReturnNotPermitted = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x08, kDAReturnNotPrivileged = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x09, kDAReturnNotReady = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x0A, kDAReturnNotWritable = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x0B, kDAReturnUnsupported = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x0C };
-typedef mach_error_t DAReturn;
-typedef const struct __DADissenter * DADissenterRef;
-extern DADissenterRef DADissenterCreate( CFAllocatorRef allocator, DAReturn status, CFStringRef string );
- at interface CIContext: NSObject {
-}
-- (CGImageRef)createCGImage:(CIImage *)im fromRect:(CGRect)r;
-- (CGImageRef)createCGImage:(CIImage *)im fromRect:(CGRect)r format:(CIFormat)f colorSpace:(CGColorSpaceRef)cs;
-- (CGLayerRef)createCGLayerWithSize:(CGSize)size info:(CFDictionaryRef)d;
- at end extern NSString* const QCRendererEventKey;
- at protocol QCCompositionRenderer - (NSDictionary*) attributes;
- at end @interface QCRenderer : NSObject <QCCompositionRenderer> {
-}
-- (id) createSnapshotImageOfType:(NSString*)type;
- at end extern NSString* const QCViewDidStartRenderingNotification;
- at interface QCView : NSView <QCCompositionRenderer> {
-}
-- (id) createSnapshotImageOfType:(NSString*)type;
- at end enum {
-ICEXIFOrientation1 = 1, ICEXIFOrientation2 = 2, ICEXIFOrientation3 = 3, ICEXIFOrientation4 = 4, ICEXIFOrientation5 = 5, ICEXIFOrientation6 = 6, ICEXIFOrientation7 = 7, ICEXIFOrientation8 = 8, };
- at class ICDevice;
- at protocol ICDeviceDelegate <NSObject> @required - (void)didRemoveDevice:(ICDevice*)device;
- at end extern NSString *const ICScannerStatusWarmingUp;
- at class ICScannerDevice;
- at protocol ICScannerDeviceDelegate <ICDeviceDelegate> @optional - (void)scannerDeviceDidBecomeAvailable:(ICScannerDevice*)scanner;
- at end
-
-typedef long unsigned int __darwin_size_t;
-typedef __darwin_size_t size_t;
-typedef unsigned long CFTypeID;
-struct CGPoint {
- CGFloat x;
- CGFloat y;
-};
-typedef struct CGPoint CGPoint;
-typedef struct CGGradient *CGGradientRef;
-typedef uint32_t CGGradientDrawingOptions;
-extern CFTypeID CGGradientGetTypeID(void);
-extern CGGradientRef CGGradientCreateWithColorComponents(CGColorSpaceRef
- space, const CGFloat components[], const CGFloat locations[], size_t count);
-extern CGGradientRef CGGradientCreateWithColors(CGColorSpaceRef space,
- CFArrayRef colors, const CGFloat locations[]);
-extern CGGradientRef CGGradientRetain(CGGradientRef gradient);
-extern void CGGradientRelease(CGGradientRef gradient);
-typedef struct CGContext *CGContextRef;
-extern void CGContextDrawLinearGradient(CGContextRef context,
- CGGradientRef gradient, CGPoint startPoint, CGPoint endPoint,
- CGGradientDrawingOptions options);
-extern CGColorSpaceRef CGColorSpaceCreateDeviceRGB(void);
-
- at interface NSMutableArray : NSObject
-- (void)addObject:(id)object;
-+ (id)array;
- at end
-
-// This is how NSMakeCollectable is declared in the OS X 10.8 headers.
-id NSMakeCollectable(CFTypeRef __attribute__((cf_consumed))) __attribute__((ns_returns_retained));
-
-typedef const struct __CFUUID * CFUUIDRef;
-
-extern
-void *CFPlugInInstanceCreate(CFAllocatorRef allocator, CFUUIDRef factoryUUID, CFUUIDRef typeUUID);
-
-//===----------------------------------------------------------------------===//
-// Test cases.
-//===----------------------------------------------------------------------===//
-
-CFAbsoluteTime f1(void) {
- CFAbsoluteTime t = CFAbsoluteTimeGetCurrent();
- CFDateRef date = CFDateCreate(0, t);
- CFRetain(date);
- CFRelease(date);
- CFDateGetAbsoluteTime(date); // no-warning
- CFRelease(date);
- t = CFDateGetAbsoluteTime(date); // expected-warning{{Reference-counted object is used after it is released}}
- return t;
-}
-
-CFAbsoluteTime f2(void) {
- CFAbsoluteTime t = CFAbsoluteTimeGetCurrent();
- CFDateRef date = CFDateCreate(0, t);
- [((NSDate*) date) retain];
- CFRelease(date);
- CFDateGetAbsoluteTime(date); // no-warning
- [((NSDate*) date) release];
- t = CFDateGetAbsoluteTime(date); // expected-warning{{Reference-counted object is used after it is released}}
- return t;
-}
-
-
-NSDate* global_x;
-
-// Test to see if we suppress an error when we store the pointer
-// to a global.
-
-CFAbsoluteTime f3(void) {
- CFAbsoluteTime t = CFAbsoluteTimeGetCurrent();
- CFDateRef date = CFDateCreate(0, t);
- [((NSDate*) date) retain];
- CFRelease(date);
- CFDateGetAbsoluteTime(date); // no-warning
- global_x = (NSDate*) date;
- [((NSDate*) date) release];
- t = CFDateGetAbsoluteTime(date); // no-warning
- return t;
-}
-
-//---------------------------------------------------------------------------
-// Test case 'f4' differs for region store and basic store. See
-// retain-release-region-store.m and retain-release-basic-store.m.
-//---------------------------------------------------------------------------
-
-// Test a leak.
-
-CFAbsoluteTime f5(int x) {
- CFAbsoluteTime t = CFAbsoluteTimeGetCurrent();
- CFDateRef date = CFDateCreate(0, t); // expected-warning{{leak}}
-
- if (x)
- CFRelease(date);
-
- return t;
-}
-
-// Test a leak involving the return.
-
-CFDateRef f6(int x) {
- CFDateRef date = CFDateCreate(0, CFAbsoluteTimeGetCurrent()); // expected-warning{{leak}}
- CFRetain(date);
- return date;
-}
-
-// Test a leak involving an overwrite.
-
-CFDateRef f7(void) {
- CFDateRef date = CFDateCreate(0, CFAbsoluteTimeGetCurrent()); //expected-warning{{leak}}
- CFRetain(date);
- date = CFDateCreate(0, CFAbsoluteTimeGetCurrent()); // expected-warning {{leak}}
- return date;
-}
-
-// Generalization of Create rule. MyDateCreate returns a CFXXXTypeRef, and
-// has the word create.
-CFDateRef MyDateCreate(void);
-
-CFDateRef f8(void) {
- CFDateRef date = MyDateCreate(); // expected-warning{{leak}}
- CFRetain(date);
- return date;
-}
-
-__attribute__((cf_returns_retained)) CFDateRef f9(void) {
- CFDateRef date = CFDateCreate(0, CFAbsoluteTimeGetCurrent()); // no-warning
- int *p = 0;
- // When allocations fail, CFDateCreate can return null.
- if (!date) *p = 1; // expected-warning{{null}}
- return date;
-}
-
-// Handle DiskArbitration API:
-//
-// http://developer.apple.com/DOCUMENTATION/DARWIN/Reference/DiscArbitrationFramework/
-//
-void f10(io_service_t media, DADiskRef d, CFStringRef s) {
- DADiskRef disk = DADiskCreateFromBSDName(kCFAllocatorDefault, 0, "hello"); // expected-warning{{leak}}
- if (disk) NSLog(@"ok");
-
- disk = DADiskCreateFromIOMedia(kCFAllocatorDefault, 0, media); // expected-warning{{leak}}
- if (disk) NSLog(@"ok");
-
- CFDictionaryRef dict = DADiskCopyDescription(d); // expected-warning{{leak}}
- if (dict) NSLog(@"ok");
-
- disk = DADiskCopyWholeDisk(d); // expected-warning{{leak}}
- if (disk) NSLog(@"ok");
-
- DADissenterRef dissenter = DADissenterCreate(kCFAllocatorDefault, // expected-warning{{leak}}
- kDAReturnSuccess, s);
- if (dissenter) NSLog(@"ok");
-
- DASessionRef session = DASessionCreate(kCFAllocatorDefault); // expected-warning{{leak}}
- if (session) NSLog(@"ok");
-}
-
-// Test retain/release checker with CFString and CFMutableArray.
-void f11(void) {
- // Create the array.
- CFMutableArrayRef A = CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks);
-
- // Create a string.
- CFStringRef s1 = CFStringCreateWithCString(0, "hello world",
- kCFStringEncodingUTF8);
-
- // Add the string to the array.
- CFArrayAppendValue(A, s1);
-
- // Decrement the reference count.
- CFRelease(s1); // no-warning
-
- // Get the string. We don't own it.
- s1 = (CFStringRef) CFArrayGetValueAtIndex(A, 0);
-
- // Release the array.
- CFRelease(A); // no-warning
-
- // Release the string. This is a bug.
- CFRelease(s1); // expected-warning{{Incorrect decrement of the reference count}}
-}
-
-// PR 3337: Handle functions declared using typedefs.
-typedef CFTypeRef CREATEFUN(void);
-CFTypeRef MyCreateFun(void);
-
-void f12(void) {
- CFTypeRef o = MyCreateFun(); // expected-warning {{leak}}
-}
-
-void f13_autorelease(void) {
- CFMutableArrayRef A = CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // no-warning
- [(id) A autorelease]; // no-warning
-}
-
-void f13_autorelease_b(void) {
- CFMutableArrayRef A = CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks);
- [(id) A autorelease];
- [(id) A autorelease];
-} // expected-warning{{Object autoreleased too many times}}
-
-CFMutableArrayRef f13_autorelease_c(void) {
- CFMutableArrayRef A = CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks);
- [(id) A autorelease];
- [(id) A autorelease];
- return A; // expected-warning{{Object autoreleased too many times}}
-}
-
-CFMutableArrayRef f13_autorelease_d(void) {
- CFMutableArrayRef A = CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks);
- [(id) A autorelease];
- [(id) A autorelease];
- CFMutableArrayRef B = CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // expected-warning{{Object autoreleased too many times}}
- CFRelease(B); // no-warning
- while (1) {}
-}
-
-
-// This case exercises the logic where the leak site is the same as the allocation site.
-void f14_leakimmediately(void) {
- CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // expected-warning{{leak}}
-}
-
-// Test that we track an allocated object beyond the point where the *name*
-// of the variable storing the reference is no longer live.
-void f15(void) {
- // Create the array.
- CFMutableArrayRef A = CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks);
- CFMutableArrayRef *B = &A;
- // At this point, the name 'A' is no longer live.
- CFRelease(*B); // no-warning
-}
-
-// Test when we pass NULL to CFRetain/CFRelease/CFMakeCollectable/CFAutorelease.
-void f16(int x, CFTypeRef p) {
- if (p)
- return;
-
- switch (x) {
- case 0:
- CFRelease(p);
- break;
- case 1:
- CFRetain(p);
- break;
- case 2:
- CFMakeCollectable(p);
- break;
- case 3:
- CFAutorelease(p);
- break;
- default:
- break;
- }
-}
-
-// Test that an object is non-null after CFRetain/CFRelease/CFMakeCollectable/CFAutorelease.
-void f17(int x, CFTypeRef p) {
- switch (x) {
- case 0:
- CFRelease(p);
- if (!p)
- CFRelease(0); // no-warning
- break;
- case 1:
- CFRetain(p);
- if (!p)
- CFRetain(0); // no-warning
- break;
- case 2:
- CFMakeCollectable(p);
- if (!p)
- CFMakeCollectable(0); // no-warning
- break;
- case 3:
- CFAutorelease(p);
- if (!p)
- CFAutorelease(0); // no-warning
- break;
- default:
- break;
- }
-}
-
-// Test basic tracking of ivars associated with 'self'. For the retain/release
-// checker we currently do not want to flag leaks associated with stores
-// of tracked objects to ivars.
- at interface SelfIvarTest : NSObject {
- id myObj;
-}
-- (void)test_self_tracking;
- at end
-
- at implementation SelfIvarTest
-- (void)test_self_tracking {
- myObj = (id) CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // no-warning
-}
- at end
-
-// Test return of non-owned objects in contexts where an owned object
-// is expected.
- at interface TestReturnNotOwnedWhenExpectedOwned
-- (NSString*)newString;
- at end
-
- at implementation TestReturnNotOwnedWhenExpectedOwned
-- (NSString*)newString {
- NSString *s = [NSString stringWithUTF8String:"hello"];
- return s; // expected-warning{{Object with a +0 retain count returned to caller where a +1 (owning) retain count is expected}}
-}
- at end
-
-int isFoo(char c);
-
-static void rdar_6659160(char *inkind, char *inname)
-{
- // We currently expect that [NSObject alloc] cannot fail. This
- // will be a toggled flag in the future. It can indeed return null, but
- // Cocoa programmers generally aren't expected to reason about out-of-memory
- // conditions.
- NSString *kind = [[NSString alloc] initWithUTF8String:inkind]; // expected-warning{{leak}}
-
- // We do allow stringWithUTF8String to fail. This isn't really correct, as
- // far as returning 0. In most error conditions it will throw an exception.
- // If allocation fails it could return 0, but again this
- // isn't expected.
- NSString *name = [NSString stringWithUTF8String:inname];
- if(!name)
- return;
-
- const char *kindC = 0;
- const char *nameC = 0;
-
- // In both cases, we cannot reach a point down below where we
- // dereference kindC or nameC with either being null. This is because
- // we assume that [NSObject alloc] doesn't fail and that we have the guard
- // up above.
-
- if(kind)
- kindC = [kind UTF8String];
- if(name)
- nameC = [name UTF8String];
- if(!isFoo(kindC[0])) // expected-warning{{null}}
- return;
- if(!isFoo(nameC[0])) // no-warning
- return;
-
- [kind release];
- [name release]; // expected-warning{{Incorrect decrement of the reference count}}
-}
-
-// PR 3677 - 'allocWithZone' should be treated as following the Cocoa naming
-// conventions with respect to 'return'ing ownership.
- at interface PR3677: NSObject @end
- at implementation PR3677
-+ (id)allocWithZone:(NSZone *)inZone {
- return [super allocWithZone:inZone]; // no-warning
-}
- at end
-
-// PR 3820 - Reason about calls to -dealloc
-void pr3820_DeallocInsteadOfRelease(void)
-{
- id foo = [[NSString alloc] init]; // no-warning
- [foo dealloc];
- // foo is not leaked, since it has been deallocated.
-}
-
-void pr3820_ReleaseAfterDealloc(void)
-{
- id foo = [[NSString alloc] init];
- [foo dealloc];
- [foo release]; // expected-warning{{used after it is release}}
- // NSInternalInconsistencyException: message sent to deallocated object
-}
-
-void pr3820_DeallocAfterRelease(void)
-{
- NSLog(@"\n\n[%s]", __FUNCTION__);
- id foo = [[NSString alloc] init];
- [foo release];
- [foo dealloc]; // expected-warning{{used after it is released}}
- // message sent to released object
-}
-
-// The problem here is that 'length' binds to '($0 - 1)' after '--length', but
-// SimpleConstraintManager doesn't know how to reason about
-// '($0 - 1) > constant'. As a temporary hack, we drop the value of '($0 - 1)'
-// and conjure a new symbol.
-void rdar6704930(unsigned char *s, unsigned int length) {
- NSString* name = 0;
- if (s != 0) {
- if (length > 0) {
- while (length > 0) {
- if (*s == ':') {
- ++s;
- --length;
- name = [[NSString alloc] init]; // no-warning
- break;
- }
- ++s;
- --length;
- }
- if ((length == 0) && (name != 0)) {
- [name release];
- name = 0;
- }
- if (length == 0) { // no ':' found -> use it all as name
- name = [[NSString alloc] init]; // no-warning
- }
- }
- }
-
- if (name != 0) {
- [name release];
- }
-}
-
-//===----------------------------------------------------------------------===//
-// One build of the analyzer accidentally stopped tracking the allocated
-// object after the 'retain'.
-//===----------------------------------------------------------------------===//
-
- at interface rdar_6833332 : NSObject <NSApplicationDelegate> {
- NSWindow *window;
-}
- at property (nonatomic, retain) NSWindow *window;
- at end
-
- at implementation rdar_6833332
- at synthesize window;
-- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
- NSMutableDictionary *dict = [[NSMutableDictionary dictionaryWithCapacity:4] retain]; // expected-warning{{leak}}
-
- [dict setObject:@"foo" forKey:@"bar"];
-
- NSLog(@"%@", dict);
-}
-- (void)dealloc {
- [window release];
- [super dealloc];
-}
-
-- (void)radar10102244 {
- NSMutableDictionary *dict = [[NSMutableDictionary dictionaryWithCapacity:4] retain]; // expected-warning{{leak}}
- if (window)
- NSLog(@"%@", window);
-}
- at end
-
-//===----------------------------------------------------------------------===//
-// clang checker fails to catch use-after-release
-//===----------------------------------------------------------------------===//
-int rdar_6257780_Case1(void) {
- NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
- NSArray *array = [NSArray array];
- [array release]; // expected-warning{{Incorrect decrement of the reference count of an object that is not owned at this point by the caller}}
- [pool drain];
- return 0;
-}
-
-//===----------------------------------------------------------------------===//
-// Analyzer is confused about NSAutoreleasePool -allocWithZone:.
-//===----------------------------------------------------------------------===//
-void rdar_10640253_autorelease_allocWithZone(void) {
- NSAutoreleasePool *pool = [[NSAutoreleasePool allocWithZone:(NSZone*)0] init];
- (void) pool;
-}
-
-//===----------------------------------------------------------------------===//
-// Checker should understand new/setObject:/release constructs
-//===----------------------------------------------------------------------===//
-void rdar_6866843(void) {
- NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
- NSMutableDictionary* dictionary = [[NSMutableDictionary alloc] init];
- NSArray* array = [[NSArray alloc] init];
- [dictionary setObject:array forKey:@"key"];
- [array release];
- // Using 'array' here should be fine
- NSLog(@"array = %@\n", array); // no-warning
- // Now the array is released
- [dictionary release];
- [pool drain];
-}
-
-
-//===----------------------------------------------------------------------===//
-// Classes typedef-ed to CF objects should get the same treatment as CF objects
-//===----------------------------------------------------------------------===//
-typedef CFTypeRef OtherRef;
-
- at interface RDar6877235 : NSObject {}
-- (CFTypeRef)_copyCFTypeRef;
-- (OtherRef)_copyOtherRef;
- at end
-
- at implementation RDar6877235
-- (CFTypeRef)_copyCFTypeRef {
- return [[NSString alloc] init]; // no-warning
-}
-- (OtherRef)_copyOtherRef {
- return [[NSString alloc] init]; // no-warning
-}
- at end
-
-//===----------------------------------------------------------------------===//
-// false positive - init method returns an object owned by caller
-//===----------------------------------------------------------------------===//
- at interface RDar6320065 : NSObject {
- NSString *_foo;
-}
-- (id)initReturningNewClass;
-- (id)_initReturningNewClassBad;
-- (id)initReturningNewClassBad2;
- at end
-
- at interface RDar6320065Subclass : RDar6320065
- at end
-
- at implementation RDar6320065
-- (id)initReturningNewClass {
- [self release];
- self = [[RDar6320065Subclass alloc] init]; // no-warning
- return self;
-}
-- (id)_initReturningNewClassBad {
- [self release];
- [[RDar6320065Subclass alloc] init]; // expected-warning {{leak}}
- return self;
-}
-- (id)initReturningNewClassBad2 {
- [self release];
- self = [[RDar6320065Subclass alloc] init];
- return [self autorelease]; // expected-warning{{Object with a +0 retain count returned to caller where a +1 (owning) retain count is expected}}
-}
-
- at end
-
- at implementation RDar6320065Subclass
- at end
-
-int RDar6320065_test(void) {
- RDar6320065 *test = [[RDar6320065 alloc] init]; // no-warning
- [test release];
- return 0;
-}
-
-//===----------------------------------------------------------------------===//
-// -awakeAfterUsingCoder: returns an owned object and claims the receiver
-//===----------------------------------------------------------------------===//
- at interface RDar7129086 : NSObject {} @end
- at implementation RDar7129086
-- (id)awakeAfterUsingCoder:(NSCoder *)aDecoder {
- [self release]; // no-warning
- return [NSString alloc]; // no-warning
-}
- at end
-
-//===----------------------------------------------------------------------===//
-// [NSData dataWithBytesNoCopy] does not return a retained object
-//===----------------------------------------------------------------------===//
- at interface RDar6859457 : NSObject {}
-- (NSString*) NoCopyString;
-- (NSString*) noCopyString;
- at end
-
- at implementation RDar6859457
-- (NSString*) NoCopyString { return [[NSString alloc] init]; } // expected-warning{{leak}}
-- (NSString*) noCopyString { return [[NSString alloc] init]; } // expected-warning{{leak}}
- at end
-
-void test_RDar6859457(RDar6859457 *x, void *bytes, NSUInteger dataLength) {
- [x NoCopyString]; // expected-warning{{leak}}
- [x noCopyString]; // expected-warning{{leak}}
- [NSData dataWithBytesNoCopy:bytes length:dataLength]; // no-warning
- [NSData dataWithBytesNoCopy:bytes length:dataLength freeWhenDone:1]; // no-warning
-}
-
-//===----------------------------------------------------------------------===//
-// PR 4230 - an autorelease pool is not necessarily leaked during a premature
-// return
-//===----------------------------------------------------------------------===//
-
-static void PR4230(void)
-{
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; // no-warning
- NSString *object = [[[NSString alloc] init] autorelease]; // no-warning
- return;
-}
-
-static void PR4230_new(void)
-{
- NSAutoreleasePool *pool = [NSAutoreleasePool new]; // no-warning
- NSString *object = [[[NSString alloc] init] autorelease]; // no-warning
- return;
-}
-
-//===----------------------------------------------------------------------===//
-// Method name that has a null IdentifierInfo* for its first selector slot.
-// This test just makes sure that we handle it.
-//===----------------------------------------------------------------------===//
- at interface TestNullIdentifier
- at end
-
- at implementation TestNullIdentifier
-+ (id):(int)x, ... {
- return [[NSString alloc] init]; // expected-warning{{leak}}
-}
- at end
-
-//===----------------------------------------------------------------------===//
-// don't flag leaks for return types that cannot be determined to be CF types
-//===----------------------------------------------------------------------===//
-
-// We don't know if 'struct s6893565' represents a Core Foundation type, so
-// we shouldn't emit an error here.
-typedef struct s6893565* TD6893565;
-
- at interface RDar6893565 {}
--(TD6893565)newThing;
- at end
-
- at implementation RDar6893565
--(TD6893565)newThing {
- return (TD6893565) [[NSString alloc] init]; // no-warning
-}
- at end
-
-//===----------------------------------------------------------------------===//
-// clang: false positives w/QC and CoreImage methods
-//===----------------------------------------------------------------------===//
-void rdar6902710(QCView *view, QCRenderer *renderer, CIContext *context,
- NSString *str, CIImage *img, CGRect rect,
- CIFormat form, CGColorSpaceRef cs) {
- [view createSnapshotImageOfType:str]; // expected-warning{{leak}}
- [renderer createSnapshotImageOfType:str]; // expected-warning{{leak}}
- [context createCGImage:img fromRect:rect]; // expected-warning{{leak}}
- [context createCGImage:img fromRect:rect format:form colorSpace:cs]; // expected-warning{{leak}}
-}
-
-//===----------------------------------------------------------------------===//
-// -[CIContext createCGLayerWithSize:info:] misinterpreted by clang scan-build
-//===----------------------------------------------------------------------===//
-void rdar6945561(CIContext *context, CGSize size, CFDictionaryRef d) {
- [context createCGLayerWithSize:size info:d]; // expected-warning{{leak}}
-}
-
-//===----------------------------------------------------------------------===//
-// Add knowledge of IOKit functions to retain/release checker.
-//===----------------------------------------------------------------------===//
-void IOBSDNameMatching_wrapper(mach_port_t mainPort, uint32_t options, const char * bsdName) {
- IOBSDNameMatching(mainPort, options, bsdName); // expected-warning{{leak}}
-}
-
-void IOServiceMatching_wrapper(const char * name) {
- IOServiceMatching(name); // expected-warning{{leak}}
-}
-
-void IOServiceNameMatching_wrapper(const char * name) {
- IOServiceNameMatching(name); // expected-warning{{leak}}
-}
-
-CF_RETURNS_RETAINED CFDictionaryRef CreateDict(void);
-
-void IOServiceAddNotification_wrapper(mach_port_t mainPort, const io_name_t notificationType,
- mach_port_t wakePort, uintptr_t reference, io_iterator_t * notification ) {
-
- CFDictionaryRef matching = CreateDict();
- CFRelease(matching);
- IOServiceAddNotification(mainPort, notificationType, matching, // expected-warning{{used after it is released}} expected-warning{{deprecated}}
- wakePort, reference, notification);
-}
-
-void IORegistryEntryIDMatching_wrapper(uint64_t entryID ) {
- IORegistryEntryIDMatching(entryID); // expected-warning{{leak}}
-}
-
-void IOOpenFirmwarePathMatching_wrapper(mach_port_t mainPort, uint32_t options,
- const char * path) {
- IOOpenFirmwarePathMatching(mainPort, options, path); // expected-warning{{leak}}
-}
-
-void IOServiceGetMatchingService_wrapper(mach_port_t mainPort) {
- CFDictionaryRef matching = CreateDict();
- IOServiceGetMatchingService(mainPort, matching);
- CFRelease(matching); // expected-warning{{used after it is released}}
-}
-
-void IOServiceGetMatchingServices_wrapper(mach_port_t mainPort, io_iterator_t *existing) {
- CFDictionaryRef matching = CreateDict();
- IOServiceGetMatchingServices(mainPort, matching, existing);
- CFRelease(matching); // expected-warning{{used after it is released}}
-}
-
-void IOServiceAddMatchingNotification_wrapper(IONotificationPortRef notifyPort, const io_name_t notificationType,
- IOServiceMatchingCallback callback, void * refCon, io_iterator_t * notification) {
-
- CFDictionaryRef matching = CreateDict();
- IOServiceAddMatchingNotification(notifyPort, notificationType, matching, callback, refCon, notification);
- CFRelease(matching); // expected-warning{{used after it is released}}
-}
-
-//===----------------------------------------------------------------------===//
-// Test of handling objects whose references "escape" to containers.
-//===----------------------------------------------------------------------===//
-void CFDictionaryAddValue(CFMutableDictionaryRef, void *, void *);
-
-void rdar_6539791(CFMutableDictionaryRef y, void* key, void* val_key) {
- CFMutableDictionaryRef x = CFDictionaryCreateMutable(kCFAllocatorDefault, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
- CFDictionaryAddValue(y, key, x);
- CFRelease(x); // the dictionary keeps a reference, so the object isn't deallocated yet
- signed z = 1;
- CFNumberRef value = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &z);
- if (value) {
- CFDictionaryAddValue(x, val_key, (void*)value); // no-warning
- CFRelease(value);
- CFDictionaryAddValue(y, val_key, (void*)value); // no-warning
- }
-}
-
-// Same issue, except with "AppendValue" functions.
-void rdar_6560661(CFMutableArrayRef x) {
- signed z = 1;
- CFNumberRef value = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &z);
- // CFArrayAppendValue keeps a reference to value.
- CFArrayAppendValue(x, value);
- CFRelease(value);
- CFRetain(value);
- CFRelease(value); // no-warning
-}
-
-// Same issue, excwept with "CFAttributeStringSetAttribute".
-void rdar_7152619(CFStringRef str) {
- CFAttributedStringRef string = CFAttributedStringCreate(kCFAllocatorDefault, str, 0);
- CFMutableAttributedStringRef attrString = CFAttributedStringCreateMutableCopy(kCFAllocatorDefault, 100, string);
- CFRelease(string);
- NSNumber *number = [[NSNumber alloc] initWithInt:5]; // expected-warning{{leak}}
- CFAttributedStringSetAttribute(attrString, CFRangeMake(0, 1), str, number);
- [number release];
- [number retain];
- CFRelease(attrString);
-}
-
-//===----------------------------------------------------------------------===//
-// Test of handling CGGradientXXX functions.
-//===----------------------------------------------------------------------===//
-
-void rdar_7184450(CGContextRef myContext, CGFloat x, CGPoint myStartPoint,
- CGPoint myEndPoint) {
- size_t num_locations = 6;
- CGFloat locations[6] = { 0.0, 0.265, 0.28, 0.31, 0.36, 1.0 };
- CGFloat components[28] = { 239.0/256.0, 167.0/256.0, 170.0/256.0,
- x, // Start color
- 207.0/255.0, 39.0/255.0, 39.0/255.0, x,
- 147.0/255.0, 21.0/255.0, 22.0/255.0, x,
- 175.0/255.0, 175.0/255.0, 175.0/255.0, x,
- 255.0/255.0,255.0/255.0, 255.0/255.0, x,
- 255.0/255.0,255.0/255.0, 255.0/255.0, x
- }; // End color
-
- CGGradientRef myGradient =
- CGGradientCreateWithColorComponents(CGColorSpaceCreateDeviceRGB(), // expected-warning{{leak}}
- components, locations, num_locations);
-
- CGContextDrawLinearGradient(myContext, myGradient, myStartPoint, myEndPoint,
- 0);
- CGGradientRelease(myGradient);
-}
-
-void rdar_7184450_pos(CGContextRef myContext, CGFloat x, CGPoint myStartPoint,
- CGPoint myEndPoint) {
- size_t num_locations = 6;
- CGFloat locations[6] = { 0.0, 0.265, 0.28, 0.31, 0.36, 1.0 };
- CGFloat components[28] = { 239.0/256.0, 167.0/256.0, 170.0/256.0,
- x, // Start color
- 207.0/255.0, 39.0/255.0, 39.0/255.0, x,
- 147.0/255.0, 21.0/255.0, 22.0/255.0, x,
- 175.0/255.0, 175.0/255.0, 175.0/255.0, x,
- 255.0/255.0,255.0/255.0, 255.0/255.0, x,
- 255.0/255.0,255.0/255.0, 255.0/255.0, x
- }; // End color
-
- CGGradientRef myGradient =
- CGGradientCreateWithColorComponents(CGColorSpaceCreateDeviceRGB(), components, locations, num_locations); // expected-warning 2 {{leak}}
-
- CGContextDrawLinearGradient(myContext, myGradient, myStartPoint, myEndPoint,
- 0);
-}
-
-//===----------------------------------------------------------------------===//
-// clang false positive: retained instance passed to thread in pthread_create
-// marked as leak
-//
-// Until we have full IPA, the analyzer should stop tracking the reference
-// count of objects passed to pthread_create.
-//
-//===----------------------------------------------------------------------===//
-struct _opaque_pthread_t {};
-struct _opaque_pthread_attr_t {};
-typedef struct _opaque_pthread_t *__darwin_pthread_t;
-typedef struct _opaque_pthread_attr_t __darwin_pthread_attr_t;
-typedef __darwin_pthread_t pthread_t;
-typedef __darwin_pthread_attr_t pthread_attr_t;
-typedef unsigned long __darwin_pthread_key_t;
-typedef __darwin_pthread_key_t pthread_key_t;
-
-int pthread_create(pthread_t *, const pthread_attr_t *,
- void *(*)(void *), void *);
-
-int pthread_setspecific(pthread_key_t key, const void *value);
-
-void *rdar_7299394_start_routine(void *p) {
- [((id) p) release];
- return 0;
-}
-void rdar_7299394(pthread_attr_t *attr, pthread_t *thread, void *args) {
- NSNumber *number = [[NSNumber alloc] initWithInt:5]; // no-warning
- pthread_create(thread, attr, rdar_7299394_start_routine, number);
-}
-void rdar_7299394_positive(pthread_attr_t *attr, pthread_t *thread) {
- NSNumber *number = [[NSNumber alloc] initWithInt:5]; // expected-warning{{leak}}
-}
-
-//===----------------------------------------------------------------------===//
-// false positive with not understanding thread local storage
-//===----------------------------------------------------------------------===//
-void rdar11282706(pthread_key_t key) {
- NSNumber *number = [[NSNumber alloc] initWithInt:5]; // no-warning
- pthread_setspecific(key, (void*) number);
-}
-
-//===----------------------------------------------------------------------===//
-// False leak associated with call to CVPixelBufferCreateWithBytes ()
-//
-// According to the Core Video Reference (ADC), CVPixelBufferCreateWithBytes and
-// CVPixelBufferCreateWithPlanarBytes can release (via a callback) the
-// pixel buffer object. These test cases show how the analyzer stops tracking
-// the reference count for the objects passed for this argument. This
-// could be made smarter.
-//===----------------------------------------------------------------------===//
-typedef int int32_t;
-typedef UInt32 FourCharCode;
-typedef FourCharCode OSType;
-typedef uint64_t CVOptionFlags;
-typedef int32_t CVReturn;
-typedef struct __CVBuffer *CVBufferRef;
-typedef CVBufferRef CVImageBufferRef;
-typedef CVImageBufferRef CVPixelBufferRef;
-typedef void (*CVPixelBufferReleaseBytesCallback)( void *releaseRefCon, const void *baseAddress );
-
-extern CVReturn CVPixelBufferCreateWithBytes(CFAllocatorRef allocator,
- size_t width,
- size_t height,
- OSType pixelFormatType,
- void *baseAddress,
- size_t bytesPerRow,
- CVPixelBufferReleaseBytesCallback releaseCallback,
- void *releaseRefCon,
- CFDictionaryRef pixelBufferAttributes,
- CVPixelBufferRef *pixelBufferOut) ;
-
-typedef void (*CVPixelBufferReleasePlanarBytesCallback)( void *releaseRefCon, const void *dataPtr, size_t dataSize, size_t numberOfPlanes, const void *planeAddresses[] );
-
-extern CVReturn CVPixelBufferCreateWithPlanarBytes(CFAllocatorRef allocator,
- size_t width,
- size_t height,
- OSType pixelFormatType,
- void *dataPtr,
- size_t dataSize,
- size_t numberOfPlanes,
- void *planeBaseAddress[],
- size_t planeWidth[],
- size_t planeHeight[],
- size_t planeBytesPerRow[],
- CVPixelBufferReleasePlanarBytesCallback releaseCallback,
- void *releaseRefCon,
- CFDictionaryRef pixelBufferAttributes,
- CVPixelBufferRef *pixelBufferOut) ;
-
-extern CVReturn CVPixelBufferCreateWithBytes(CFAllocatorRef allocator,
- size_t width,
- size_t height,
- OSType pixelFormatType,
- void *baseAddress,
- size_t bytesPerRow,
- CVPixelBufferReleaseBytesCallback releaseCallback,
- void *releaseRefCon,
- CFDictionaryRef pixelBufferAttributes,
- CVPixelBufferRef *pixelBufferOut) ;
-
-CVReturn rdar_7283567(CFAllocatorRef allocator, size_t width, size_t height,
- OSType pixelFormatType, void *baseAddress,
- size_t bytesPerRow,
- CVPixelBufferReleaseBytesCallback releaseCallback,
- CFDictionaryRef pixelBufferAttributes,
- CVPixelBufferRef *pixelBufferOut) {
-
- // For the allocated object, it doesn't really matter what type it is
- // for the purpose of this test. All we want to show is that
- // this is freed later by the callback.
- NSNumber *number = [[NSNumber alloc] initWithInt:5]; // no-warning
-
- return CVPixelBufferCreateWithBytes(allocator, width, height, pixelFormatType,
- baseAddress, bytesPerRow, releaseCallback,
- number, // potentially released by callback
- pixelBufferAttributes, pixelBufferOut) ;
-}
-
-CVReturn rdar_7283567_2(CFAllocatorRef allocator, size_t width, size_t height,
- OSType pixelFormatType, void *dataPtr, size_t dataSize,
- size_t numberOfPlanes, void *planeBaseAddress[],
- size_t planeWidth[], size_t planeHeight[], size_t planeBytesPerRow[],
- CVPixelBufferReleasePlanarBytesCallback releaseCallback,
- CFDictionaryRef pixelBufferAttributes,
- CVPixelBufferRef *pixelBufferOut) {
-
- // For the allocated object, it doesn't really matter what type it is
- // for the purpose of this test. All we want to show is that
- // this is freed later by the callback.
- NSNumber *number = [[NSNumber alloc] initWithInt:5]; // no-warning
-
- return CVPixelBufferCreateWithPlanarBytes(allocator,
- width, height, pixelFormatType, dataPtr, dataSize,
- numberOfPlanes, planeBaseAddress, planeWidth,
- planeHeight, planeBytesPerRow, releaseCallback,
- number, // potentially released by callback
- pixelBufferAttributes, pixelBufferOut) ;
-}
-
-//===----------------------------------------------------------------------===//
-// False leak associated with CGBitmapContextCreateWithData
-//===----------------------------------------------------------------------===//
-typedef uint32_t CGBitmapInfo;
-typedef void (*CGBitmapContextReleaseDataCallback)(void *releaseInfo, void *data);
-
-CGContextRef CGBitmapContextCreateWithData(void *data,
- size_t width, size_t height, size_t bitsPerComponent,
- size_t bytesPerRow, CGColorSpaceRef space, CGBitmapInfo bitmapInfo,
- CGBitmapContextReleaseDataCallback releaseCallback, void *releaseInfo);
-
-void rdar_7358899(void *data,
- size_t width, size_t height, size_t bitsPerComponent,
- size_t bytesPerRow, CGColorSpaceRef space, CGBitmapInfo bitmapInfo,
- CGBitmapContextReleaseDataCallback releaseCallback) {
-
- // For the allocated object, it doesn't really matter what type it is
- // for the purpose of this test. All we want to show is that
- // this is freed later by the callback.
- NSNumber *number = [[NSNumber alloc] initWithInt:5]; // no-warning
-
- CGBitmapContextCreateWithData(data, width, height, bitsPerComponent, // expected-warning{{leak}}
- bytesPerRow, space, bitmapInfo, releaseCallback, number);
-}
-
-//===----------------------------------------------------------------------===//
-// Allow 'new', 'copy', 'alloc', 'init' prefix to start before '_' when
-// determining Cocoa fundamental rule.
-//
-// Previously the retain/release checker just skipped prefixes before the
-// first '_' entirely. Now the checker honors the prefix if it results in a
-// recognizable naming convention (e.g., 'new', 'init').
-//===----------------------------------------------------------------------===//
- at interface RDar7265711 {}
-- (id) new_stuff;
- at end
-
-void rdar7265711_a(RDar7265711 *x) {
- id y = [x new_stuff]; // expected-warning{{leak}}
-}
-
-void rdar7265711_b(RDar7265711 *x) {
- id y = [x new_stuff]; // no-warning
- [y release];
-}
-
-//===----------------------------------------------------------------------===//
-// clang thinks [NSCursor dragCopyCursor] returns a retained reference
-//===----------------------------------------------------------------------===//
- at interface NSCursor : NSObject
-+ (NSCursor *)dragCopyCursor;
- at end
-
-void rdar7306898(void) {
- // 'dragCopyCursor' does not follow Cocoa's fundamental rule. It is a noun, not an sentence
- // implying a 'copy' of something.
- NSCursor *c = [NSCursor dragCopyCursor]; // no-warning
- NSNumber *number = [[NSNumber alloc] initWithInt:5]; // expected-warning{{leak}}
-}
-
-//===----------------------------------------------------------------------===//
-// Sending 'release', 'retain', etc. to a Class directly is not likely what the
-// user intended.
-//===----------------------------------------------------------------------===//
- at interface RDar7252064 : NSObject @end
-void rdar7252064(void) {
- [RDar7252064 release]; // expected-warning{{The 'release' message should be sent to instances of class 'RDar7252064' and not the class directly}}
- [RDar7252064 retain]; // expected-warning{{The 'retain' message should be sent to instances of class 'RDar7252064' and not the class directly}}
- [RDar7252064 autorelease]; // expected-warning{{The 'autorelease' message should be sent to instances of class 'RDar7252064' and not the class directly}}
- [NSAutoreleasePool drain]; // expected-warning{{method '+drain' not found}} expected-warning{{The 'drain' message should be sent to instances of class 'NSAutoreleasePool' and not the class directly}}
-}
-
-//===----------------------------------------------------------------------===//
-// Tests of ownership attributes.
-//===----------------------------------------------------------------------===//
-
-typedef NSString* MyStringTy;
-
- at protocol FooP;
-
- at interface TestOwnershipAttr : NSObject
-- (NSString*) returnsAnOwnedString NS_RETURNS_RETAINED; // no-warning
-- (NSString*) returnsAnOwnedCFString CF_RETURNS_RETAINED; // no-warning
-- (MyStringTy) returnsAnOwnedTypedString NS_RETURNS_RETAINED; // no-warning
-- (NSString*) newString NS_RETURNS_NOT_RETAINED; // no-warning
-- (NSString*) newString_auto NS_RETURNS_AUTORELEASED; // no-warning
-- (NSString*) newStringNoAttr;
-- (int) returnsAnOwnedInt NS_RETURNS_RETAINED; // expected-warning{{'ns_returns_retained' attribute only applies to methods that return an Objective-C object}}
-- (id) pseudoInit NS_CONSUMES_SELF NS_RETURNS_RETAINED;
-+ (void) consume:(id) NS_CONSUMED x;
-+ (void) consume2:(id) CF_CONSUMED x;
- at end
-
-static int ownership_attribute_doesnt_go_here NS_RETURNS_RETAINED; // expected-warning{{'ns_returns_retained' attribute only applies to functions and methods}}
-
-void test_attr_1(TestOwnershipAttr *X) {
- NSString *str = [X returnsAnOwnedString]; // expected-warning{{leak}}
-}
-
-void test_attr_1b(TestOwnershipAttr *X) {
- NSString *str = [X returnsAnOwnedCFString]; // expected-warning{{leak}}
-}
-
-void test_attr1c(TestOwnershipAttr *X) {
- NSString *str = [X newString]; // no-warning
- NSString *str2 = [X newStringNoAttr]; // expected-warning{{leak}}
- NSString *str3 = [X newString_auto]; // no-warning
- NSString *str4 = [[X newString_auto] retain]; // expected-warning {{leak}}
-}
-
-void testattr2_a(void) {
- TestOwnershipAttr *x = [TestOwnershipAttr alloc]; // expected-warning{{leak}}
-}
-
-void testattr2_b(void) {
- TestOwnershipAttr *x = [[TestOwnershipAttr alloc] pseudoInit]; // expected-warning{{leak}}
-}
-
-void testattr2_b_11358224_self_assign_looses_the_leak(void) {
- TestOwnershipAttr *x = [[TestOwnershipAttr alloc] pseudoInit];// expected-warning{{leak}}
- x = x;
-}
-
-void testattr2_c(void) {
- TestOwnershipAttr *x = [[TestOwnershipAttr alloc] pseudoInit]; // no-warning
- [x release];
-}
-
-void testattr3(void) {
- TestOwnershipAttr *x = [TestOwnershipAttr alloc]; // no-warning
- [TestOwnershipAttr consume:x];
- TestOwnershipAttr *y = [TestOwnershipAttr alloc]; // no-warning
- [TestOwnershipAttr consume2:y];
-}
-
-void consume_ns(id NS_CONSUMED x);
-void consume_cf(id CF_CONSUMED x);
-
-void testattr4(void) {
- TestOwnershipAttr *x = [TestOwnershipAttr alloc]; // no-warning
- consume_ns(x);
- TestOwnershipAttr *y = [TestOwnershipAttr alloc]; // no-warning
- consume_cf(y);
-}
-
- at interface TestOwnershipAttr2 : NSObject
-- (NSString*) newString NS_RETURNS_NOT_RETAINED; // no-warning
- at end
-
- at implementation TestOwnershipAttr2
-- (NSString*) newString {
- return [NSString alloc]; // expected-warning {{Potential leak of an object}}
-}
- at end
-
- at interface MyClassTestCFAttr : NSObject {}
-- (NSDate*) returnsCFRetained CF_RETURNS_RETAINED;
-- (CFDateRef) returnsCFRetainedAsCF CF_RETURNS_RETAINED;
-- (CFDateRef) newCFRetainedAsCF CF_RETURNS_NOT_RETAINED;
-- (CFDateRef) newCFRetainedAsCFNoAttr;
-- (NSDate*) alsoReturnsRetained;
-- (CFDateRef) alsoReturnsRetainedAsCF;
-- (NSDate*) returnsNSRetained NS_RETURNS_RETAINED;
- at end
-
-CF_RETURNS_RETAINED
-CFDateRef returnsRetainedCFDate(void) {
- return CFDateCreate(0, CFAbsoluteTimeGetCurrent());
-}
-
- at implementation MyClassTestCFAttr
-- (NSDate*) returnsCFRetained {
- return (NSDate*) returnsRetainedCFDate(); // No leak.
-}
-
-- (CFDateRef) returnsCFRetainedAsCF {
- return returnsRetainedCFDate(); // No leak.
-}
-
-- (CFDateRef) newCFRetainedAsCF {
- return (CFDateRef)[(id)[self returnsCFRetainedAsCF] autorelease];
-}
-
-- (CFDateRef) newCFRetainedAsCFNoAttr {
- return (CFDateRef)[(id)[self returnsCFRetainedAsCF] autorelease]; // expected-warning{{Object with a +0 retain count returned to caller where a +1 (owning) retain count is expected}}
-}
-
-- (NSDate*) alsoReturnsRetained {
- return (NSDate*) returnsRetainedCFDate(); // expected-warning{{leak}}
-}
-
-- (CFDateRef) alsoReturnsRetainedAsCF {
- return returnsRetainedCFDate(); // expected-warning{{leak}}
-}
-
-
-- (NSDate*) returnsNSRetained {
- return (NSDate*) returnsRetainedCFDate(); // no-warning
-}
- at end
-
-//===----------------------------------------------------------------------===//
-// Test that leaks post-dominated by "panic" functions are not reported.
-//
-// Do not report a leak when post-dominated by a call to a noreturn or panic
-// function.
-//===----------------------------------------------------------------------===//
-void panic(void) __attribute__((noreturn));
-void panic_not_in_hardcoded_list(void) __attribute__((noreturn));
-
-void test_panic_negative(void) {
- signed z = 1;
- CFNumberRef value = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &z); // expected-warning{{leak}}
-}
-
-void test_panic_positive(void) {
- signed z = 1;
- CFNumberRef value = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &z); // no-warning
- panic();
-}
-
-void test_panic_neg_2(int x) {
- signed z = 1;
- CFNumberRef value = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &z); // expected-warning{{leak}}
- if (x)
- panic();
-}
-
-void test_panic_pos_2(int x) {
- signed z = 1;
- CFNumberRef value = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &z); // no-warning
- if (x)
- panic();
- if (!x) {
- // This showed up previously where we silently missed checking the function
- // type for noreturn. "panic()" is a hard-coded known panic function that
- // isn't always noreturn.
- panic_not_in_hardcoded_list();
- }
-}
-
-//===----------------------------------------------------------------------===//
-// Test uses of blocks (closures)
-//===----------------------------------------------------------------------===//
-
-void test_blocks_1_pos(void) {
- NSNumber *number = [[NSNumber alloc] initWithInt:5]; // expected-warning{{leak}}
- ^{}();
-}
-
-void test_blocks_1_indirect_release(void) {
- NSNumber *number = [[NSNumber alloc] initWithInt:5]; // no-warning
- ^{ [number release]; }();
-}
-
-void test_blocks_1_indirect_retain(void) {
- // Eventually this should be reported as a leak.
- NSNumber *number = [[NSNumber alloc] initWithInt:5]; // no-warning
- ^{ [number retain]; }();
-}
-
-void test_blocks_1_indirect_release_via_call(void) {
- NSNumber *number = [[NSNumber alloc] initWithInt:5]; // no-warning
- ^(NSObject *o){ [o release]; }(number);
-}
-
-void test_blocks_1_indirect_retain_via_call(void) {
- NSNumber *number = [[NSNumber alloc] initWithInt:5]; // expected-warning {{leak}}
- ^(NSObject *o){ [o retain]; }(number);
-}
-
-//===--------------------------------------------------------------------===//
-// Test sending message to super that returns an object alias. Previously
-// this caused a crash in the analyzer.
-//===--------------------------------------------------------------------===//
-
- at interface Rdar8015556 : NSObject {} @end
- at implementation Rdar8015556
-- (id)retain {
- return [super retain];
-}
- at end
-
-// Correcly handle Class<...> in Cocoa Conventions detector.
- at protocol Prot_R8272168 @end
-Class <Prot_R8272168> GetAClassThatImplementsProt_R8272168(void);
-void r8272168(void) {
- GetAClassThatImplementsProt_R8272168();
-}
-
-// Test case which in the past triggered a false positive.
- at interface RDar8356342
-- (NSDate*) rdar8356342:(NSDate *)inValue;
- at end
-
- at implementation RDar8356342
-- (NSDate*) rdar8356342:(NSDate*)inValue {
- NSDate *outValue = inValue;
- if (outValue == 0)
- outValue = [[NSDate alloc] init]; // no-warning
-
- if (outValue != inValue)
- [outValue autorelease];
-
- return outValue;
-}
- at end
-
-// This test case previously crashed because of a bug in BugReporter.
-extern const void *CFDictionaryGetValue(CFDictionaryRef theDict, const void *key);
-typedef struct __CFError * CFErrorRef;
-extern const CFStringRef kCFErrorUnderlyingErrorKey;
-extern CFDictionaryRef CFErrorCopyUserInfo(CFErrorRef err);
-static void rdar_8724287(CFErrorRef error)
-{
- CFErrorRef error_to_dump;
-
- error_to_dump = error;
- while (error_to_dump != ((void*)0)) {
- CFDictionaryRef info;
-
- info = CFErrorCopyUserInfo(error_to_dump); // expected-warning{{Potential leak of an object}}
-
- if (info != ((void*)0)) {
- }
-
- error_to_dump = (CFErrorRef) CFDictionaryGetValue(info, kCFErrorUnderlyingErrorKey);
- }
-}
-
-// Make sure the model applies cf_consumed correctly in argument positions
-// besides the first.
-extern void *CFStringCreate(void);
-extern void rdar_9234108_helper(void *key, void * CF_CONSUMED value);
-void rdar_9234108(void) {
- rdar_9234108_helper(0, CFStringCreate());
-}
-
-// Make sure that objc_method_family works to override naming conventions.
-struct TwoDoubles {
- double one;
- double two;
-};
-typedef struct TwoDoubles TwoDoubles;
-
- at interface NSValue (Mine)
-- (id)_prefix_initWithTwoDoubles:(TwoDoubles)twoDoubles __attribute__((objc_method_family(init)));
- at end
-
- at implementation NSValue (Mine)
-- (id)_prefix_initWithTwoDoubles:(TwoDoubles)twoDoubles
-{
- return [self init];
-}
- at end
-
-void rdar9726279(void) {
- TwoDoubles twoDoubles = { 0.0, 0.0 };
- NSValue *value = [[NSValue alloc] _prefix_initWithTwoDoubles:twoDoubles];
- [value release];
-}
-
-// Test camelcase support for CF conventions. While Core Foundation APIs
-// don't use camel casing, other code is allowed to use it.
-CFArrayRef camelcase_create_1(void) {
- return CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // no-warning
-}
-
-CFArrayRef camelcase_createno(void) {
- return CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // expected-warning {{leak}}
-}
-
-CFArrayRef camelcase_copy(void) {
- return CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // no-warning
-}
-
-CFArrayRef camelcase_copying(void) {
- return CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // expected-warning {{leak}}
-}
-
-CFArrayRef copyCamelCase(void) {
- return CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // no-warning
-}
-
-CFArrayRef __copyCamelCase(void) {
- return CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // no-warning
-}
-
-CFArrayRef __createCamelCase(void) {
- return CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // no-warning
-}
-
-CFArrayRef camel_create(void) {
- return CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // no-warning
-}
-
-
-CFArrayRef camel_creat(void) {
- return CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // expected-warning {{leak}}
-}
-
-CFArrayRef camel_copy(void) {
- return CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // no-warning
-}
-
-CFArrayRef camel_copyMachine(void) {
- return CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // no-warning
-}
-
-CFArrayRef camel_copymachine(void) {
- return CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // expected-warning {{leak}}
-}
-
- at protocol F18P
-- (id) clone;
- at end
- at interface F18 : NSObject<F18P> @end
- at interface F18(Cat)
-- (id) clone NS_RETURNS_RETAINED;
- at end
-
- at implementation F18
-- (id) clone {
- return [F18 alloc];
-}
- at end
-
-void rdar6582778(void) {
- CFAbsoluteTime t = CFAbsoluteTimeGetCurrent();
- CFTypeRef vals[] = { CFDateCreate(0, t) }; // expected-warning {{leak}}
-}
-
-CFTypeRef global;
-
-void rdar6582778_2(void) {
- CFAbsoluteTime t = CFAbsoluteTimeGetCurrent();
- global = CFDateCreate(0, t); // no-warning
-}
-
-// Test that objects passed to containers are marked "escaped".
-void rdar10232019(void) {
- NSMutableArray *array = [NSMutableArray array];
-
- NSString *string = [[NSString alloc] initWithUTF8String:"foo"];
- [array addObject:string];
- [string release];
-
- NSString *otherString = [string stringByAppendingString:@"bar"]; // no-warning
- NSLog(@"%@", otherString);
-}
-
-void rdar10232019_positive(void) {
- NSMutableArray *array = [NSMutableArray array];
-
- NSString *string = [[NSString alloc] initWithUTF8String:"foo"];
- [string release];
-
- NSString *otherString = [string stringByAppendingString:@"bar"]; // expected-warning {{Reference-counted object is used after it is release}}
- NSLog(@"%@", otherString);
-}
-
-// RetainCountChecker support for XPC.
-typedef void * xpc_object_t;
-xpc_object_t _CFXPCCreateXPCObjectFromCFObject(CFTypeRef cf);
-void xpc_release(xpc_object_t object);
-
-void rdar9658496(void) {
- CFStringRef cf;
- xpc_object_t xpc;
- cf = CFStringCreateWithCString( ((CFAllocatorRef)0), "test", kCFStringEncodingUTF8 ); // no-warning
- xpc = _CFXPCCreateXPCObjectFromCFObject( cf );
- CFRelease(cf);
- xpc_release(xpc);
-}
-
-// Support annotations with method families.
- at interface RDar10824732 : NSObject
-- (id)initWithObj:(id CF_CONSUMED)obj;
- at end
-
- at implementation RDar10824732
-- (id)initWithObj:(id)obj {
- [obj release];
- return [super init];
-}
- at end
-
-void rdar_10824732(void) {
- @autoreleasepool {
- NSString *obj = @"test";
- RDar10824732 *foo = [[RDar10824732 alloc] initWithObj:obj]; // no-warning
- [foo release];
- }
-}
-
-// Stop tracking objects passed to functions, which take callbacks as parameters.
-typedef int (*CloseCallback) (void *);
-void ReaderForIO(CloseCallback ioclose, void *ioctx);
-int IOClose(void *context);
-
- at protocol SInS <NSObject>
- at end
-
- at interface radar10973977 : NSObject
-- (id<SInS>)inputS;
-- (void)reader;
- at end
-
- at implementation radar10973977
-- (void)reader
-{
- id<SInS> inputS = [[self inputS] retain];
- ReaderForIO(IOClose, inputS);
-}
-- (id<SInS>)inputS
-{
- return 0;
-}
- at end
-
-// Object escapes through a selector callback
-extern id NSApp;
- at interface MySheetController
-- (id<SInS>)inputS;
-- (void)showDoSomethingSheetAction:(id)action;
-- (void)sheetDidEnd:(NSWindow *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo;
- at end
-
- at implementation MySheetController
-- (id<SInS>)inputS {
- return 0;
-}
-- (void)showDoSomethingSheetAction:(id)action {
- id<SInS> inputS = [[self inputS] retain];
- [NSApp beginSheet:0
- modalForWindow:0
- modalDelegate:0
- didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:)
- contextInfo:(void *)inputS]; // no - warning
-}
-- (void)sheetDidEnd:(NSWindow *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo {
-
- id contextObject = (id)contextInfo;
- [contextObject release];
-}
-
-- (id)copyAutoreleaseRadar13081402 {
- id x = [[[NSString alloc] initWithUTF8String:"foo"] autorelease];
- [x retain];
- return x; // no warning
-}
-
- at end
-//===----------------------------------------------------------------------===//
-// Test returning allocated memory in a struct.
-//
-// We currently don't have a general way to track pointers that "escape".
-// Here we test that RetainCountChecker doesn't get excited about returning
-// allocated CF objects in struct fields.
-//===----------------------------------------------------------------------===//
-void *malloc(size_t);
-struct rdar11104566 { CFStringRef myStr; };
-struct rdar11104566 test_rdar11104566(void) {
- CFStringRef cf = CFStringCreateWithCString( ((CFAllocatorRef)0), "test", kCFStringEncodingUTF8 ); // no-warning
- struct rdar11104566 V;
- V.myStr = cf;
- return V; // no-warning
-}
-
-struct rdar11104566 *test_2_rdar11104566(void) {
- CFStringRef cf = CFStringCreateWithCString( ((CFAllocatorRef)0), "test", kCFStringEncodingUTF8 ); // no-warning
- struct rdar11104566 *V = (struct rdar11104566 *) malloc(sizeof(*V));
- V->myStr = cf;
- return V; // no-warning
-}
-
-//===----------------------------------------------------------------------===//
-// ObjC literals support.
-//===----------------------------------------------------------------------===//
-
-void test_objc_arrays(void) {
- { // CASE ONE -- OBJECT IN ARRAY CREATED DIRECTLY
- NSObject *o = [[NSObject alloc] init];
- NSArray *a = [[NSArray alloc] initWithObjects:o, (void*)0]; // expected-warning {{leak}}
- [o release];
- [a description];
- [o description];
- }
-
- { // CASE TWO -- OBJECT IN ARRAY CREATED BY DUPING AUTORELEASED ARRAY
- NSObject *o = [[NSObject alloc] init];
- NSArray *a1 = [NSArray arrayWithObjects:o, (void*)0];
- NSArray *a2 = [[NSArray alloc] initWithArray:a1]; // expected-warning {{leak}}
- [o release];
- [a2 description];
- [o description];
- }
-
- { // CASE THREE -- OBJECT IN RETAINED @[]
- NSObject *o = [[NSObject alloc] init];
- NSArray *a3 = [@[o] retain]; // expected-warning {{leak}}
- [o release];
- [a3 description];
- [o description];
- }
-
- { // CASE FOUR -- OBJECT IN ARRAY CREATED BY DUPING @[]
- NSObject *o = [[NSObject alloc] init];
- NSArray *a = [[NSArray alloc] initWithArray:@[o]]; // expected-warning {{leak}}
- [o release];
-
- [a description];
- [o description];
- }
-
- { // CASE FIVE -- OBJECT IN RETAINED @{}
- NSValue *o = [[NSValue alloc] init];
- NSDictionary *a = [@{o : o} retain]; // expected-warning {{leak}}
- [o release];
-
- [a description];
- [o description];
- }
-}
-
-void test_objc_integer_literals(void) {
- id value = [@1 retain]; // expected-warning {{leak}}
- [value description];
-}
-
-void test_objc_boxed_expressions(int x, const char *y) {
- id value = [@(x) retain]; // expected-warning {{leak}}
- [value description];
-
- value = [@(y) retain]; // expected-warning {{leak}}
- [value description];
-}
-
-// Test NSLog doesn't escape tracked objects.
-void rdar11400885(int y)
-{
- @autoreleasepool {
- NSString *printString;
- if(y > 2)
- printString = [[NSString alloc] init];
- else
- printString = [[NSString alloc] init];
- NSLog(@"Once %@", printString);
- [printString release];
- NSLog(@"Again: %@", printString); // expected-warning {{Reference-counted object is used after it is released}}
- }
-}
-
-id makeCollectableNonLeak(void) {
- extern CFTypeRef CFCreateSomething(void);
-
- CFTypeRef object = CFCreateSomething(); // +1
- CFRetain(object); // +2
- id objCObject = NSMakeCollectable(object); // +2
- [objCObject release]; // +1
- return [objCObject autorelease]; // +0
-}
-
-
-void consumeAndStopTracking(id NS_CONSUMED obj, void (^callback)(void));
-void CFConsumeAndStopTracking(CFTypeRef CF_CONSUMED obj, void (^callback)(void));
-
-void testConsumeAndStopTracking(void) {
- id retained = [@[] retain]; // +1
- consumeAndStopTracking(retained, ^{}); // no-warning
-
- id doubleRetained = [[@[] retain] retain]; // +2
- consumeAndStopTracking(doubleRetained, ^{
- [doubleRetained release];
- }); // no-warning
-
- id unretained = @[]; // +0
- consumeAndStopTracking(unretained, ^{}); // expected-warning {{Incorrect decrement of the reference count of an object that is not owned at this point by the caller}}
-}
-
-void testCFConsumeAndStopTracking(void) {
- id retained = [@[] retain]; // +1
- CFConsumeAndStopTracking((CFTypeRef)retained, ^{}); // no-warning
-
- id doubleRetained = [[@[] retain] retain]; // +2
- CFConsumeAndStopTracking((CFTypeRef)doubleRetained, ^{
- [doubleRetained release];
- }); // no-warning
-
- id unretained = @[]; // +0
- CFConsumeAndStopTracking((CFTypeRef)unretained, ^{}); // expected-warning {{Incorrect decrement of the reference count of an object that is not owned at this point by the caller}}
-}
-//===----------------------------------------------------------------------===//
-// Test 'pragma clang arc_cf_code_audited' support.
-//===----------------------------------------------------------------------===//
-
-typedef void *MyCFType;
-#pragma clang arc_cf_code_audited begin
-MyCFType CreateMyCFType(void);
-#pragma clang arc_cf_code_audited end
-
-void test_custom_cf(void) {
- MyCFType x = CreateMyCFType(); // expected-warning {{leak of an object stored into 'x'}}
-}
-
-//===----------------------------------------------------------------------===//
-// Test calling CFPlugInInstanceCreate, which appears in CF but doesn't
-// return a CF object.
-//===----------------------------------------------------------------------===//
-
-void test_CFPlugInInstanceCreate(CFUUIDRef factoryUUID, CFUUIDRef typeUUID) {
- CFPlugInInstanceCreate(kCFAllocatorDefault, factoryUUID, typeUUID); // no-warning
-}
-
-//===----------------------------------------------------------------------===//
-// PR14927: -drain only has retain-count semantics on NSAutoreleasePool.
-//===----------------------------------------------------------------------===//
-
- at interface PR14927 : NSObject
-- (void)drain;
- at end
-
-void test_drain(void) {
- PR14927 *obj = [[PR14927 alloc] init];
- [obj drain];
- [obj release]; // no-warning
-}
-
-//===----------------------------------------------------------------------===//
-// Allow cf_returns_retained and cf_returns_not_retained to mark a return
-// value as tracked, even if the object isn't a known CF type.
-//===----------------------------------------------------------------------===//
-
-MyCFType getCustom(void) __attribute__((cf_returns_not_retained));
-MyCFType makeCustom(void) __attribute__((cf_returns_retained));
-
-void testCustomReturnsRetained(void) {
- MyCFType obj = makeCustom(); // expected-warning {{leak of an object stored into 'obj'}}
-}
-
-void testCustomReturnsNotRetained(void) {
- CFRelease(getCustom()); // expected-warning {{Incorrect decrement of the reference count of an object that is not owned at this point by the caller}}
-}
-
-//===----------------------------------------------------------------------===//
-// Don't print variables which are out of the current scope.
-//===----------------------------------------------------------------------===//
- at interface MyObj12706177 : NSObject
--(id)initX;
-+(void)test12706177;
- at end
-static int Cond;
- at implementation MyObj12706177
--(id)initX {
- if (Cond)
- return 0;
- self = [super init];
- return self;
-}
-+(void)test12706177 {
- id x = [[MyObj12706177 alloc] initX]; //expected-warning {{Potential leak of an object}}
- [x release];
-}
- at end
-
-//===----------------------------------------------------------------------===//
-// xpc_connection_set_finalizer_f
-//===----------------------------------------------------------------------===//
-typedef xpc_object_t xpc_connection_t;
-typedef void (*xpc_finalizer_t)(void *value);
-void xpc_connection_set_context(xpc_connection_t connection, void *ctx);
-void xpc_connection_set_finalizer_f(xpc_connection_t connection,
- xpc_finalizer_t finalizer);
-void releaseAfterXPC(void *context) {
- [(NSArray *)context release];
-}
-
-void rdar13783514(xpc_connection_t connection) {
- xpc_connection_set_context(connection, [[NSMutableArray alloc] init]);
- xpc_connection_set_finalizer_f(connection, releaseAfterXPC);
-} // no-warning
-
-CFAttributedStringRef CFAttributedCreate(void *CFObj CF_CONSUMED) CF_RETURNS_RETAINED;
-
- at interface Action
-- (SEL)action;
-- (void)setAction:(SEL)aSelector;
-- (id) target;
-- (void)setTarget:(id)aTarget;
- at end
diff --git a/clang/test/ARCMT/objcmt-arc-cf-annotations.m.result b/clang/test/ARCMT/objcmt-arc-cf-annotations.m.result
deleted file mode 100644
index 1e941297848805..00000000000000
--- a/clang/test/ARCMT/objcmt-arc-cf-annotations.m.result
+++ /dev/null
@@ -1,2063 +0,0 @@
-// RUN: rm -rf %t
-// RUN: %clang_cc1 -fblocks -objcmt-migrate-annotation -objcmt-migrate-instancetype -objcmt-migrate-readwrite-property -mt-migrate-directory %t %s -x objective-c -triple x86_64-apple-darwin11
-// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result
-// RUN: %clang_cc1 -fblocks -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s.result
-
-#ifndef CF_IMPLICIT_BRIDGING_ENABLED
-#if __has_feature(arc_cf_code_audited)
-#define CF_IMPLICIT_BRIDGING_ENABLED _Pragma("clang arc_cf_code_audited begin")
-#else
-#define CF_IMPLICIT_BRIDGING_ENABLED
-#endif
-#endif
-
-#ifndef CF_IMPLICIT_BRIDGING_DISABLED
-#if __has_feature(arc_cf_code_audited)
-#define CF_IMPLICIT_BRIDGING_DISABLED _Pragma("clang arc_cf_code_audited end")
-#else
-#define CF_IMPLICIT_BRIDGING_DISABLED
-#endif
-#endif
-
-#if __has_feature(attribute_ns_returns_retained)
-#define NS_RETURNS_RETAINED __attribute__((ns_returns_retained))
-#endif
-#if __has_feature(attribute_cf_returns_retained)
-#define CF_RETURNS_RETAINED __attribute__((cf_returns_retained))
-#endif
-#if __has_feature(attribute_ns_returns_not_retained)
-#define NS_RETURNS_NOT_RETAINED __attribute__((ns_returns_not_retained))
-#endif
-#if __has_feature(attribute_cf_returns_not_retained)
-#define CF_RETURNS_NOT_RETAINED __attribute__((cf_returns_not_retained))
-#endif
-#if __has_feature(attribute_ns_consumes_self)
-#define NS_CONSUMES_SELF __attribute__((ns_consumes_self))
-#endif
-#if __has_feature(attribute_ns_consumed)
-#define NS_CONSUMED __attribute__((ns_consumed))
-#endif
-#if __has_feature(attribute_cf_consumed)
-#define CF_CONSUMED __attribute__((cf_consumed))
-#endif
-#if __has_attribute(ns_returns_autoreleased)
-#define NS_RETURNS_AUTORELEASED __attribute__((ns_returns_autoreleased))
-#endif
-
-//===----------------------------------------------------------------------===//
-// The following code is reduced using delta-debugging from Mac OS X headers:
-//
-// #include <Cocoa/Cocoa.h>
-// #include <CoreFoundation/CoreFoundation.h>
-// #include <DiskArbitration/DiskArbitration.h>
-// #include <QuartzCore/QuartzCore.h>
-// #include <Quartz/Quartz.h>
-// #include <IOKit/IOKitLib.h>
-//
-// It includes the basic definitions for the test cases below.
-//===----------------------------------------------------------------------===//
-
-typedef unsigned int __darwin_natural_t;
-typedef unsigned long uintptr_t;
-typedef unsigned int uint32_t;
-typedef unsigned long long uint64_t;
-typedef unsigned int UInt32;
-typedef signed long CFIndex;
-typedef CFIndex CFByteOrder;
-typedef struct {
- CFIndex location;
- CFIndex length;
-} CFRange;
-static __inline__ __attribute__((always_inline)) CFRange CFRangeMake(CFIndex loc, CFIndex len) {
- CFRange range;
- range.location = loc;
- range.length = len;
- return range;
-}
-typedef const void * CFTypeRef;
-typedef const struct __CFString * CFStringRef;
-typedef const struct __CFAllocator * CFAllocatorRef;
-extern const CFAllocatorRef kCFAllocatorDefault;
-extern CFTypeRef CFRetain(CFTypeRef cf);
-
-CF_IMPLICIT_BRIDGING_ENABLED
-
-extern void CFRelease(CFTypeRef cf);
-
-CF_IMPLICIT_BRIDGING_DISABLED
-
-extern CFTypeRef CFAutorelease(CFTypeRef cf);
-extern CFTypeRef CFMakeCollectable(CFTypeRef cf);
-typedef struct {
-}
-CFArrayCallBacks;
-extern const CFArrayCallBacks kCFTypeArrayCallBacks;
-typedef const struct __CFArray * CFArrayRef;
-typedef struct __CFArray * CFMutableArrayRef;
-extern CFMutableArrayRef CFArrayCreateMutable(CFAllocatorRef allocator, CFIndex capacity, const CFArrayCallBacks *callBacks) CF_RETURNS_RETAINED;
-extern const void *CFArrayGetValueAtIndex(CFArrayRef theArray, CFIndex idx) CF_RETURNS_NOT_RETAINED;
-extern void CFArrayAppendValue(CFMutableArrayRef theArray, const void *value);
-typedef struct {
-}
-CFDictionaryKeyCallBacks;
-extern const CFDictionaryKeyCallBacks kCFTypeDictionaryKeyCallBacks;
-typedef struct {
-}
-CFDictionaryValueCallBacks;
-extern const CFDictionaryValueCallBacks kCFTypeDictionaryValueCallBacks;
-typedef const struct __CFDictionary * CFDictionaryRef;
-typedef struct __CFDictionary * CFMutableDictionaryRef;
-extern CFMutableDictionaryRef CFDictionaryCreateMutable(CFAllocatorRef allocator, CFIndex capacity, const CFDictionaryKeyCallBacks *keyCallBacks, const CFDictionaryValueCallBacks *valueCallBacks) CF_RETURNS_RETAINED;
-typedef UInt32 CFStringEncoding;
-enum {
-kCFStringEncodingMacRoman = 0, kCFStringEncodingWindowsLatin1 = 0x0500, kCFStringEncodingISOLatin1 = 0x0201, kCFStringEncodingNextStepLatin = 0x0B01, kCFStringEncodingASCII = 0x0600, kCFStringEncodingUnicode = 0x0100, kCFStringEncodingUTF8 = 0x08000100, kCFStringEncodingNonLossyASCII = 0x0BFF , kCFStringEncodingUTF16 = 0x0100, kCFStringEncodingUTF16BE = 0x10000100, kCFStringEncodingUTF16LE = 0x14000100, kCFStringEncodingUTF32 = 0x0c000100, kCFStringEncodingUTF32BE = 0x18000100, kCFStringEncodingUTF32LE = 0x1c000100 };
-extern CFStringRef CFStringCreateWithCString(CFAllocatorRef alloc, const char *cStr, CFStringEncoding encoding) CF_RETURNS_RETAINED;
-typedef double CFTimeInterval;
-typedef CFTimeInterval CFAbsoluteTime;
-extern CFAbsoluteTime CFAbsoluteTimeGetCurrent(void);
-typedef const struct __CFDate * CFDateRef;
-extern CFDateRef CFDateCreate(CFAllocatorRef allocator, CFAbsoluteTime at) CF_RETURNS_RETAINED;
-extern CFAbsoluteTime CFDateGetAbsoluteTime(CFDateRef theDate);
-typedef __darwin_natural_t natural_t;
-typedef natural_t mach_port_name_t;
-typedef mach_port_name_t mach_port_t;
-typedef int kern_return_t;
-typedef kern_return_t mach_error_t;
-enum {
-kCFNumberSInt8Type = 1, kCFNumberSInt16Type = 2, kCFNumberSInt32Type = 3, kCFNumberSInt64Type = 4, kCFNumberFloat32Type = 5, kCFNumberFloat64Type = 6, kCFNumberCharType = 7, kCFNumberShortType = 8, kCFNumberIntType = 9, kCFNumberLongType = 10, kCFNumberLongLongType = 11, kCFNumberFloatType = 12, kCFNumberDoubleType = 13, kCFNumberCFIndexType = 14, kCFNumberNSIntegerType = 15, kCFNumberCGFloatType = 16, kCFNumberMaxType = 16 };
-typedef CFIndex CFNumberType;
-typedef const struct __CFNumber * CFNumberRef;
-extern CFNumberRef CFNumberCreate(CFAllocatorRef allocator, CFNumberType theType, const void *valuePtr) CF_RETURNS_RETAINED;
-typedef const struct __CFAttributedString *CFAttributedStringRef;
-typedef struct __CFAttributedString *CFMutableAttributedStringRef;
-extern CFAttributedStringRef CFAttributedStringCreate(CFAllocatorRef alloc, CFStringRef str, CFDictionaryRef attributes) CF_RETURNS_RETAINED ;
-extern CFMutableAttributedStringRef CFAttributedStringCreateMutableCopy(CFAllocatorRef alloc, CFIndex maxLength, CFAttributedStringRef aStr) CF_RETURNS_RETAINED ;
-extern void CFAttributedStringSetAttribute(CFMutableAttributedStringRef aStr, CFRange range, CFStringRef attrName, CFTypeRef value) ;
-typedef signed char BOOL;
-typedef unsigned long NSUInteger;
- at class NSString, Protocol;
-extern void NSLog(NSString *format, ...) __attribute__((format(__NSString__, 1, 2)));
-typedef struct _NSZone NSZone;
- at class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
- at protocol NSObject
-- (BOOL)isEqual:(id)object;
-- (id)retain;
-- (oneway void)release;
-- (id)autorelease;
-- (NSString *)description;
-- (instancetype)init;
- at end
- at protocol NSCopying
-- (id)copyWithZone:(NSZone *)zone;
- at end
- at protocol NSMutableCopying - (id)mutableCopyWithZone:(NSZone *)zone;
- at end
- at protocol NSCoding - (void)encodeWithCoder:(NSCoder *)aCoder;
- at end
- at interface NSObject <NSObject> {}
-+ (id)allocWithZone:(NSZone *)zone;
-+ (id)alloc;
-+ (id)new;
-- (void)dealloc;
- at end
- at interface NSObject (NSCoderMethods)
-- (id)awakeAfterUsingCoder:(NSCoder *)aDecoder;
- at end
-extern id NSAllocateObject(Class aClass, NSUInteger extraBytes, NSZone *zone);
-typedef struct {
-}
-NSFastEnumerationState;
- at protocol NSFastEnumeration
-- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id *)stackbuf count:(NSUInteger)len;
- at end
- at class NSString, NSDictionary;
- at interface NSValue : NSObject <NSCopying, NSCoding> - (void)getValue:(void *)value;
- at end
- at interface NSNumber : NSValue
-- (char)charValue;
-- (instancetype)initWithInt:(int)value;
-+ (NSNumber *)numberWithInt:(int)value;
- at end
- at class NSString;
- at interface NSArray : NSObject <NSCopying, NSMutableCopying, NSCoding, NSFastEnumeration>
-- (NSUInteger)count;
-- (instancetype)initWithObjects:(const id [])objects count:(NSUInteger)cnt;
-+ (instancetype)arrayWithObject:(id)anObject;
-+ (instancetype)arrayWithObjects:(const id [])objects count:(NSUInteger)cnt;
-+ (instancetype)arrayWithObjects:(id)firstObj, ... __attribute__((sentinel(0,1)));
-- (instancetype)initWithObjects:(id)firstObj, ... __attribute__((sentinel(0,1)));
-- (instancetype)initWithArray:(NSArray *)array;
- at end @interface NSArray (NSArrayCreation) + (instancetype)array;
- at end @interface NSAutoreleasePool : NSObject {
-}
-- (void)drain;
- at end extern NSString * const NSBundleDidLoadNotification;
-typedef double NSTimeInterval;
- at interface NSDate : NSObject <NSCopying, NSCoding> - (NSTimeInterval)timeIntervalSinceReferenceDate;
- at end typedef unsigned short unichar;
- at interface NSString : NSObject <NSCopying, NSMutableCopying, NSCoding>
-- (NSUInteger)length;
-- (NSString *)stringByAppendingString:(NSString *)aString;
-- ( const char *)UTF8String;
-- (instancetype)initWithUTF8String:(const char *)nullTerminatedCString;
-+ (instancetype)stringWithUTF8String:(const char *)nullTerminatedCString;
- at end @class NSString, NSURL, NSError;
- at interface NSData : NSObject <NSCopying, NSMutableCopying, NSCoding> - (NSUInteger)length;
-+ (instancetype)dataWithBytesNoCopy:(void *)bytes length:(NSUInteger)length;
-+ (instancetype)dataWithBytesNoCopy:(void *)bytes length:(NSUInteger)length freeWhenDone:(BOOL)b;
- at end @class NSLocale, NSDate, NSCalendar, NSTimeZone, NSError, NSArray, NSMutableDictionary;
- at interface NSDictionary : NSObject <NSCopying, NSMutableCopying, NSCoding, NSFastEnumeration>
-- (NSUInteger)count;
-+ (instancetype)dictionaryWithObjects:(NSArray *)objects forKeys:(NSArray *)keys;
-+ (instancetype)dictionaryWithObjects:(const id [])objects forKeys:(const id <NSCopying> [])keys count:(NSUInteger)cnt;
- at end
- at interface NSMutableDictionary : NSDictionary - (void)removeObjectForKey:(id)aKey;
-- (void)setObject:(id)anObject forKey:(id)aKey;
- at end @interface NSMutableDictionary (NSMutableDictionaryCreation) + (instancetype)dictionaryWithCapacity:(NSUInteger)numItems;
- at end typedef double CGFloat;
-struct CGSize {
-};
-typedef struct CGSize CGSize;
-struct CGRect {
-};
-typedef struct CGRect CGRect;
-typedef mach_port_t io_object_t;
-typedef char io_name_t[128];
-typedef io_object_t io_iterator_t;
-typedef io_object_t io_service_t;
-typedef struct IONotificationPort * IONotificationPortRef;
-typedef void (*IOServiceMatchingCallback)( void * refcon, io_iterator_t iterator );
-
-CF_IMPLICIT_BRIDGING_ENABLED
-
-io_service_t IOServiceGetMatchingService( mach_port_t mainPort, CFDictionaryRef matching );
-kern_return_t IOServiceGetMatchingServices( mach_port_t mainPort, CFDictionaryRef matching, io_iterator_t * existing );
-
-CF_IMPLICIT_BRIDGING_DISABLED
-
-kern_return_t IOServiceAddNotification( mach_port_t mainPort, const io_name_t notificationType, CFDictionaryRef matching, mach_port_t wakePort, uintptr_t reference, io_iterator_t * notification ) __attribute__((deprecated)); // expected-note {{'IOServiceAddNotification' declared here}}
-kern_return_t IOServiceAddMatchingNotification( IONotificationPortRef notifyPort, const io_name_t notificationType, CFDictionaryRef CF_CONSUMED matching, IOServiceMatchingCallback callback, void * refCon, io_iterator_t * notification );
-
-CF_IMPLICIT_BRIDGING_ENABLED
-
-CFMutableDictionaryRef IOServiceMatching( const char * name );
-CFMutableDictionaryRef IOServiceNameMatching( const char * name );
-CFMutableDictionaryRef IOBSDNameMatching( mach_port_t mainPort, uint32_t options, const char * bsdName );
-CFMutableDictionaryRef IOOpenFirmwarePathMatching( mach_port_t mainPort, uint32_t options, const char * path );
-CFMutableDictionaryRef IORegistryEntryIDMatching( uint64_t entryID );
-
-CF_IMPLICIT_BRIDGING_DISABLED
-
-typedef struct __DASession * DASessionRef;
-extern DASessionRef DASessionCreate( CFAllocatorRef allocator ) CF_RETURNS_RETAINED;
-typedef struct __DADisk * DADiskRef;
-extern DADiskRef DADiskCreateFromBSDName( CFAllocatorRef allocator, DASessionRef session, const char * name ) CF_RETURNS_RETAINED;
-extern DADiskRef DADiskCreateFromIOMedia( CFAllocatorRef allocator, DASessionRef session, io_service_t media ) CF_RETURNS_RETAINED;
-extern CFDictionaryRef DADiskCopyDescription( DADiskRef disk ) CF_RETURNS_RETAINED;
-extern DADiskRef DADiskCopyWholeDisk( DADiskRef disk ) CF_RETURNS_RETAINED;
- at interface NSTask : NSObject - (instancetype)init;
- at end typedef struct CGColorSpace *CGColorSpaceRef;
-typedef struct CGImage *CGImageRef;
-typedef struct CGLayer *CGLayerRef;
- at interface NSResponder : NSObject <NSCoding> {
-}
- at end @protocol NSAnimatablePropertyContainer - (id)animator;
- at end extern NSString *NSAnimationTriggerOrderIn ;
- at interface NSView : NSResponder <NSAnimatablePropertyContainer> {
-}
- at end @protocol NSValidatedUserInterfaceItem - (SEL)action;
- at end @protocol NSUserInterfaceValidations - (BOOL)validateUserInterfaceItem:(id <NSValidatedUserInterfaceItem>)anItem;
- at end @class NSDate, NSDictionary, NSError, NSException, NSNotification;
- at class NSTextField, NSPanel, NSArray, NSWindow, NSImage, NSButton, NSError;
- at interface NSApplication : NSResponder <NSUserInterfaceValidations> {
-}
-- (void)beginSheet:(NSWindow *)sheet modalForWindow:(NSWindow *)docWindow modalDelegate:(id)modalDelegate didEndSelector:(SEL)didEndSelector contextInfo:(void *)contextInfo;
- at end enum {
-NSTerminateCancel = 0, NSTerminateNow = 1, NSTerminateLater = 2 };
-typedef NSUInteger NSApplicationTerminateReply;
- at protocol NSApplicationDelegate <NSObject> @optional - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender;
- at end @class NSAttributedString, NSEvent, NSFont, NSFormatter, NSImage, NSMenu, NSText, NSView, NSTextView;
- at interface NSCell : NSObject <NSCopying, NSCoding> {
-}
- at end
-typedef struct {
-}
-CVTimeStamp;
- at interface CIImage : NSObject <NSCoding, NSCopying> {
-}
-typedef int CIFormat;
- at end enum {
-kDAReturnSuccess = 0, kDAReturnError = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x01, kDAReturnBusy = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x02, kDAReturnBadArgument = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x03, kDAReturnExclusiveAccess = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x04, kDAReturnNoResources = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x05, kDAReturnNotFound = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x06, kDAReturnNotMounted = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x07, kDAReturnNotPermitted = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x08, kDAReturnNotPrivileged = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x09, kDAReturnNotReady = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x0A, kDAReturnNotWritable = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x0B, kDAReturnUnsupported = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x0C };
-typedef mach_error_t DAReturn;
-typedef const struct __DADissenter * DADissenterRef;
-extern DADissenterRef DADissenterCreate( CFAllocatorRef allocator, DAReturn status, CFStringRef string ) CF_RETURNS_RETAINED;
- at interface CIContext: NSObject {
-}
-- (CGImageRef)createCGImage:(CIImage *)im fromRect:(CGRect)r CF_RETURNS_RETAINED;
-- (CGImageRef)createCGImage:(CIImage *)im fromRect:(CGRect)r format:(CIFormat)f colorSpace:(CGColorSpaceRef)cs CF_RETURNS_RETAINED;
-- (CGLayerRef)createCGLayerWithSize:(CGSize)size info:(CFDictionaryRef)d CF_RETURNS_RETAINED;
- at end extern NSString* const QCRendererEventKey;
- at protocol QCCompositionRenderer - (NSDictionary*) attributes;
- at end @interface QCRenderer : NSObject <QCCompositionRenderer> {
-}
-- (id) createSnapshotImageOfType:(NSString*)type NS_RETURNS_RETAINED;
- at end extern NSString* const QCViewDidStartRenderingNotification;
- at interface QCView : NSView <QCCompositionRenderer> {
-}
-- (id) createSnapshotImageOfType:(NSString*)type NS_RETURNS_RETAINED;
- at end enum {
-ICEXIFOrientation1 = 1, ICEXIFOrientation2 = 2, ICEXIFOrientation3 = 3, ICEXIFOrientation4 = 4, ICEXIFOrientation5 = 5, ICEXIFOrientation6 = 6, ICEXIFOrientation7 = 7, ICEXIFOrientation8 = 8, };
- at class ICDevice;
- at protocol ICDeviceDelegate <NSObject> @required - (void)didRemoveDevice:(ICDevice*)device;
- at end extern NSString *const ICScannerStatusWarmingUp;
- at class ICScannerDevice;
- at protocol ICScannerDeviceDelegate <ICDeviceDelegate> @optional - (void)scannerDeviceDidBecomeAvailable:(ICScannerDevice*)scanner;
- at end
-
-typedef long unsigned int __darwin_size_t;
-typedef __darwin_size_t size_t;
-typedef unsigned long CFTypeID;
-struct CGPoint {
- CGFloat x;
- CGFloat y;
-};
-typedef struct CGPoint CGPoint;
-typedef struct CGGradient *CGGradientRef;
-typedef uint32_t CGGradientDrawingOptions;
-extern CFTypeID CGGradientGetTypeID(void);
-extern CGGradientRef CGGradientCreateWithColorComponents(CGColorSpaceRef
- space, const CGFloat components[], const CGFloat locations[], size_t count) CF_RETURNS_RETAINED;
-extern CGGradientRef CGGradientCreateWithColors(CGColorSpaceRef space,
- CFArrayRef colors, const CGFloat locations[]) CF_RETURNS_RETAINED;
-extern CGGradientRef CGGradientRetain(CGGradientRef gradient);
-
-CF_IMPLICIT_BRIDGING_ENABLED
-
-extern void CGGradientRelease(CGGradientRef gradient);
-
-CF_IMPLICIT_BRIDGING_DISABLED
-
-typedef struct CGContext *CGContextRef;
-extern void CGContextDrawLinearGradient(CGContextRef context,
- CGGradientRef gradient, CGPoint startPoint, CGPoint endPoint,
- CGGradientDrawingOptions options);
-
-CF_IMPLICIT_BRIDGING_ENABLED
-
-extern CGColorSpaceRef CGColorSpaceCreateDeviceRGB(void);
-
-CF_IMPLICIT_BRIDGING_DISABLED
-
-
- at interface NSMutableArray : NSObject
-- (void)addObject:(id)object;
-+ (instancetype)array;
- at end
-
-// This is how NSMakeCollectable is declared in the OS X 10.8 headers.
-id NSMakeCollectable(CFTypeRef __attribute__((cf_consumed))) __attribute__((ns_returns_retained));
-
-typedef const struct __CFUUID * CFUUIDRef;
-
-extern
-void *CFPlugInInstanceCreate(CFAllocatorRef allocator, CFUUIDRef factoryUUID, CFUUIDRef typeUUID);
-
-//===----------------------------------------------------------------------===//
-// Test cases.
-//===----------------------------------------------------------------------===//
-
-CFAbsoluteTime f1(void) {
- CFAbsoluteTime t = CFAbsoluteTimeGetCurrent();
- CFDateRef date = CFDateCreate(0, t);
- CFRetain(date);
- CFRelease(date);
- CFDateGetAbsoluteTime(date); // no-warning
- CFRelease(date);
- t = CFDateGetAbsoluteTime(date); // expected-warning{{Reference-counted object is used after it is released}}
- return t;
-}
-
-CFAbsoluteTime f2(void) {
- CFAbsoluteTime t = CFAbsoluteTimeGetCurrent();
- CFDateRef date = CFDateCreate(0, t);
- [((NSDate*) date) retain];
- CFRelease(date);
- CFDateGetAbsoluteTime(date); // no-warning
- [((NSDate*) date) release];
- t = CFDateGetAbsoluteTime(date); // expected-warning{{Reference-counted object is used after it is released}}
- return t;
-}
-
-
-NSDate* global_x;
-
-// Test to see if we suppress an error when we store the pointer
-// to a global.
-
-CFAbsoluteTime f3(void) {
- CFAbsoluteTime t = CFAbsoluteTimeGetCurrent();
- CFDateRef date = CFDateCreate(0, t);
- [((NSDate*) date) retain];
- CFRelease(date);
- CFDateGetAbsoluteTime(date); // no-warning
- global_x = (NSDate*) date;
- [((NSDate*) date) release];
- t = CFDateGetAbsoluteTime(date); // no-warning
- return t;
-}
-
-//---------------------------------------------------------------------------
-// Test case 'f4' differs for region store and basic store. See
-// retain-release-region-store.m and retain-release-basic-store.m.
-//---------------------------------------------------------------------------
-
-// Test a leak.
-
-CFAbsoluteTime f5(int x) {
- CFAbsoluteTime t = CFAbsoluteTimeGetCurrent();
- CFDateRef date = CFDateCreate(0, t); // expected-warning{{leak}}
-
- if (x)
- CFRelease(date);
-
- return t;
-}
-
-// Test a leak involving the return.
-
-CFDateRef f6(int x) {
- CFDateRef date = CFDateCreate(0, CFAbsoluteTimeGetCurrent()); // expected-warning{{leak}}
- CFRetain(date);
- return date;
-}
-
-// Test a leak involving an overwrite.
-
-CFDateRef f7(void) {
- CFDateRef date = CFDateCreate(0, CFAbsoluteTimeGetCurrent()); //expected-warning{{leak}}
- CFRetain(date);
- date = CFDateCreate(0, CFAbsoluteTimeGetCurrent()); // expected-warning {{leak}}
- return date;
-}
-
-// Generalization of Create rule. MyDateCreate returns a CFXXXTypeRef, and
-// has the word create.
-
-CF_IMPLICIT_BRIDGING_ENABLED
-
-CFDateRef MyDateCreate(void);
-
-CF_IMPLICIT_BRIDGING_DISABLED
-
-
-CFDateRef f8(void) {
- CFDateRef date = MyDateCreate(); // expected-warning{{leak}}
- CFRetain(date);
- return date;
-}
-
-__attribute__((cf_returns_retained)) CFDateRef f9(void) {
- CFDateRef date = CFDateCreate(0, CFAbsoluteTimeGetCurrent()); // no-warning
- int *p = 0;
- // When allocations fail, CFDateCreate can return null.
- if (!date) *p = 1; // expected-warning{{null}}
- return date;
-}
-
-// Handle DiskArbitration API:
-//
-// http://developer.apple.com/DOCUMENTATION/DARWIN/Reference/DiscArbitrationFramework/
-//
-void f10(io_service_t media, DADiskRef d, CFStringRef s) {
- DADiskRef disk = DADiskCreateFromBSDName(kCFAllocatorDefault, 0, "hello"); // expected-warning{{leak}}
- if (disk) NSLog(@"ok");
-
- disk = DADiskCreateFromIOMedia(kCFAllocatorDefault, 0, media); // expected-warning{{leak}}
- if (disk) NSLog(@"ok");
-
- CFDictionaryRef dict = DADiskCopyDescription(d); // expected-warning{{leak}}
- if (dict) NSLog(@"ok");
-
- disk = DADiskCopyWholeDisk(d); // expected-warning{{leak}}
- if (disk) NSLog(@"ok");
-
- DADissenterRef dissenter = DADissenterCreate(kCFAllocatorDefault, // expected-warning{{leak}}
- kDAReturnSuccess, s);
- if (dissenter) NSLog(@"ok");
-
- DASessionRef session = DASessionCreate(kCFAllocatorDefault); // expected-warning{{leak}}
- if (session) NSLog(@"ok");
-}
-
-// Test retain/release checker with CFString and CFMutableArray.
-void f11(void) {
- // Create the array.
- CFMutableArrayRef A = CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks);
-
- // Create a string.
- CFStringRef s1 = CFStringCreateWithCString(0, "hello world",
- kCFStringEncodingUTF8);
-
- // Add the string to the array.
- CFArrayAppendValue(A, s1);
-
- // Decrement the reference count.
- CFRelease(s1); // no-warning
-
- // Get the string. We don't own it.
- s1 = (CFStringRef) CFArrayGetValueAtIndex(A, 0);
-
- // Release the array.
- CFRelease(A); // no-warning
-
- // Release the string. This is a bug.
- CFRelease(s1); // expected-warning{{Incorrect decrement of the reference count}}
-}
-
-// PR 3337: Handle functions declared using typedefs.
-typedef CFTypeRef CREATEFUN(void);
-
-CF_IMPLICIT_BRIDGING_ENABLED
-
-CFTypeRef MyCreateFun(void);
-
-CF_IMPLICIT_BRIDGING_DISABLED
-
-
-void f12(void) {
- CFTypeRef o = MyCreateFun(); // expected-warning {{leak}}
-}
-
-void f13_autorelease(void) {
- CFMutableArrayRef A = CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // no-warning
- [(id) A autorelease]; // no-warning
-}
-
-void f13_autorelease_b(void) {
- CFMutableArrayRef A = CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks);
- [(id) A autorelease];
- [(id) A autorelease];
-} // expected-warning{{Object autoreleased too many times}}
-
-CFMutableArrayRef f13_autorelease_c(void) {
- CFMutableArrayRef A = CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks);
- [(id) A autorelease];
- [(id) A autorelease];
- return A; // expected-warning{{Object autoreleased too many times}}
-}
-
-CFMutableArrayRef f13_autorelease_d(void) {
- CFMutableArrayRef A = CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks);
- [(id) A autorelease];
- [(id) A autorelease];
- CFMutableArrayRef B = CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // expected-warning{{Object autoreleased too many times}}
- CFRelease(B); // no-warning
- while (1) {}
-}
-
-
-// This case exercises the logic where the leak site is the same as the allocation site.
-void f14_leakimmediately(void) {
- CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // expected-warning{{leak}}
-}
-
-// Test that we track an allocated object beyond the point where the *name*
-// of the variable storing the reference is no longer live.
-void f15(void) {
- // Create the array.
- CFMutableArrayRef A = CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks);
- CFMutableArrayRef *B = &A;
- // At this point, the name 'A' is no longer live.
- CFRelease(*B); // no-warning
-}
-
-// Test when we pass NULL to CFRetain/CFRelease/CFMakeCollectable/CFAutorelease.
-void f16(int x, CFTypeRef p) {
- if (p)
- return;
-
- switch (x) {
- case 0:
- CFRelease(p);
- break;
- case 1:
- CFRetain(p);
- break;
- case 2:
- CFMakeCollectable(p);
- break;
- case 3:
- CFAutorelease(p);
- break;
- default:
- break;
- }
-}
-
-// Test that an object is non-null after CFRetain/CFRelease/CFMakeCollectable/CFAutorelease.
-void f17(int x, CFTypeRef p) {
- switch (x) {
- case 0:
- CFRelease(p);
- if (!p)
- CFRelease(0); // no-warning
- break;
- case 1:
- CFRetain(p);
- if (!p)
- CFRetain(0); // no-warning
- break;
- case 2:
- CFMakeCollectable(p);
- if (!p)
- CFMakeCollectable(0); // no-warning
- break;
- case 3:
- CFAutorelease(p);
- if (!p)
- CFAutorelease(0); // no-warning
- break;
- default:
- break;
- }
-}
-
-// Test basic tracking of ivars associated with 'self'. For the retain/release
-// checker we currently do not want to flag leaks associated with stores
-// of tracked objects to ivars.
- at interface SelfIvarTest : NSObject {
- id myObj;
-}
-- (void)test_self_tracking;
- at end
-
- at implementation SelfIvarTest
-- (void)test_self_tracking {
- myObj = (id) CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // no-warning
-}
- at end
-
-// Test return of non-owned objects in contexts where an owned object
-// is expected.
- at interface TestReturnNotOwnedWhenExpectedOwned
-- (NSString*)newString;
- at end
-
- at implementation TestReturnNotOwnedWhenExpectedOwned
-- (NSString*)newString {
- NSString *s = [NSString stringWithUTF8String:"hello"];
- return s; // expected-warning{{Object with a +0 retain count returned to caller where a +1 (owning) retain count is expected}}
-}
- at end
-
-int isFoo(char c);
-
-static void rdar_6659160(char *inkind, char *inname)
-{
- // We currently expect that [NSObject alloc] cannot fail. This
- // will be a toggled flag in the future. It can indeed return null, but
- // Cocoa programmers generally aren't expected to reason about out-of-memory
- // conditions.
- NSString *kind = [[NSString alloc] initWithUTF8String:inkind]; // expected-warning{{leak}}
-
- // We do allow stringWithUTF8String to fail. This isn't really correct, as
- // far as returning 0. In most error conditions it will throw an exception.
- // If allocation fails it could return 0, but again this
- // isn't expected.
- NSString *name = [NSString stringWithUTF8String:inname];
- if(!name)
- return;
-
- const char *kindC = 0;
- const char *nameC = 0;
-
- // In both cases, we cannot reach a point down below where we
- // dereference kindC or nameC with either being null. This is because
- // we assume that [NSObject alloc] doesn't fail and that we have the guard
- // up above.
-
- if(kind)
- kindC = [kind UTF8String];
- if(name)
- nameC = [name UTF8String];
- if(!isFoo(kindC[0])) // expected-warning{{null}}
- return;
- if(!isFoo(nameC[0])) // no-warning
- return;
-
- [kind release];
- [name release]; // expected-warning{{Incorrect decrement of the reference count}}
-}
-
-// PR 3677 - 'allocWithZone' should be treated as following the Cocoa naming
-// conventions with respect to 'return'ing ownership.
- at interface PR3677: NSObject @end
- at implementation PR3677
-+ (id)allocWithZone:(NSZone *)inZone {
- return [super allocWithZone:inZone]; // no-warning
-}
- at end
-
-// PR 3820 - Reason about calls to -dealloc
-void pr3820_DeallocInsteadOfRelease(void)
-{
- id foo = [[NSString alloc] init]; // no-warning
- [foo dealloc];
- // foo is not leaked, since it has been deallocated.
-}
-
-void pr3820_ReleaseAfterDealloc(void)
-{
- id foo = [[NSString alloc] init];
- [foo dealloc];
- [foo release]; // expected-warning{{used after it is release}}
- // NSInternalInconsistencyException: message sent to deallocated object
-}
-
-void pr3820_DeallocAfterRelease(void)
-{
- NSLog(@"\n\n[%s]", __FUNCTION__);
- id foo = [[NSString alloc] init];
- [foo release];
- [foo dealloc]; // expected-warning{{used after it is released}}
- // message sent to released object
-}
-
-// The problem here is that 'length' binds to '($0 - 1)' after '--length', but
-// SimpleConstraintManager doesn't know how to reason about
-// '($0 - 1) > constant'. As a temporary hack, we drop the value of '($0 - 1)'
-// and conjure a new symbol.
-void rdar6704930(unsigned char *s, unsigned int length) {
- NSString* name = 0;
- if (s != 0) {
- if (length > 0) {
- while (length > 0) {
- if (*s == ':') {
- ++s;
- --length;
- name = [[NSString alloc] init]; // no-warning
- break;
- }
- ++s;
- --length;
- }
- if ((length == 0) && (name != 0)) {
- [name release];
- name = 0;
- }
- if (length == 0) { // no ':' found -> use it all as name
- name = [[NSString alloc] init]; // no-warning
- }
- }
- }
-
- if (name != 0) {
- [name release];
- }
-}
-
-//===----------------------------------------------------------------------===//
-// One build of the analyzer accidentally stopped tracking the allocated
-// object after the 'retain'.
-//===----------------------------------------------------------------------===//
-
- at interface rdar_6833332 : NSObject <NSApplicationDelegate> {
- NSWindow *window;
-}
- at property (nonatomic, retain) NSWindow *window;
- at end
-
- at implementation rdar_6833332
- at synthesize window;
-- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
- NSMutableDictionary *dict = [[NSMutableDictionary dictionaryWithCapacity:4] retain]; // expected-warning{{leak}}
-
- [dict setObject:@"foo" forKey:@"bar"];
-
- NSLog(@"%@", dict);
-}
-- (void)dealloc {
- [window release];
- [super dealloc];
-}
-
-- (void)radar10102244 {
- NSMutableDictionary *dict = [[NSMutableDictionary dictionaryWithCapacity:4] retain]; // expected-warning{{leak}}
- if (window)
- NSLog(@"%@", window);
-}
- at end
-
-//===----------------------------------------------------------------------===//
-// clang checker fails to catch use-after-release
-//===----------------------------------------------------------------------===//
-int rdar_6257780_Case1(void) {
- NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
- NSArray *array = [NSArray array];
- [array release]; // expected-warning{{Incorrect decrement of the reference count of an object that is not owned at this point by the caller}}
- [pool drain];
- return 0;
-}
-
-//===----------------------------------------------------------------------===//
-// Analyzer is confused about NSAutoreleasePool -allocWithZone:.
-//===----------------------------------------------------------------------===//
-void rdar_10640253_autorelease_allocWithZone(void) {
- NSAutoreleasePool *pool = [[NSAutoreleasePool allocWithZone:(NSZone*)0] init];
- (void) pool;
-}
-
-//===----------------------------------------------------------------------===//
-// Checker should understand new/setObject:/release constructs
-//===----------------------------------------------------------------------===//
-void rdar_6866843(void) {
- NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
- NSMutableDictionary* dictionary = [[NSMutableDictionary alloc] init];
- NSArray* array = [[NSArray alloc] init];
- [dictionary setObject:array forKey:@"key"];
- [array release];
- // Using 'array' here should be fine
- NSLog(@"array = %@\n", array); // no-warning
- // Now the array is released
- [dictionary release];
- [pool drain];
-}
-
-
-//===----------------------------------------------------------------------===//
-// Classes typedef-ed to CF objects should get the same treatment as CF objects
-//===----------------------------------------------------------------------===//
-typedef CFTypeRef OtherRef;
-
- at interface RDar6877235 : NSObject {}
-- (CFTypeRef)_copyCFTypeRef CF_RETURNS_RETAINED;
-- (OtherRef)_copyOtherRef CF_RETURNS_RETAINED;
- at end
-
- at implementation RDar6877235
-- (CFTypeRef)_copyCFTypeRef {
- return [[NSString alloc] init]; // no-warning
-}
-- (OtherRef)_copyOtherRef {
- return [[NSString alloc] init]; // no-warning
-}
- at end
-
-//===----------------------------------------------------------------------===//
-// false positive - init method returns an object owned by caller
-//===----------------------------------------------------------------------===//
- at interface RDar6320065 : NSObject {
- NSString *_foo;
-}
-- (instancetype)initReturningNewClass;
-- (id)_initReturningNewClassBad;
-- (instancetype)initReturningNewClassBad2;
- at end
-
- at interface RDar6320065Subclass : RDar6320065
- at end
-
- at implementation RDar6320065
-- (instancetype)initReturningNewClass {
- [self release];
- self = [[RDar6320065Subclass alloc] init]; // no-warning
- return self;
-}
-- (id)_initReturningNewClassBad {
- [self release];
- [[RDar6320065Subclass alloc] init]; // expected-warning {{leak}}
- return self;
-}
-- (instancetype)initReturningNewClassBad2 {
- [self release];
- self = [[RDar6320065Subclass alloc] init];
- return [self autorelease]; // expected-warning{{Object with a +0 retain count returned to caller where a +1 (owning) retain count is expected}}
-}
-
- at end
-
- at implementation RDar6320065Subclass
- at end
-
-int RDar6320065_test(void) {
- RDar6320065 *test = [[RDar6320065 alloc] init]; // no-warning
- [test release];
- return 0;
-}
-
-//===----------------------------------------------------------------------===//
-// -awakeAfterUsingCoder: returns an owned object and claims the receiver
-//===----------------------------------------------------------------------===//
- at interface RDar7129086 : NSObject {} @end
- at implementation RDar7129086
-- (id)awakeAfterUsingCoder:(NSCoder *)aDecoder {
- [self release]; // no-warning
- return [NSString alloc]; // no-warning
-}
- at end
-
-//===----------------------------------------------------------------------===//
-// [NSData dataWithBytesNoCopy] does not return a retained object
-//===----------------------------------------------------------------------===//
- at interface RDar6859457 : NSObject {}
-- (NSString*) NoCopyString;
-- (NSString*) noCopyString;
- at end
-
- at implementation RDar6859457
-- (NSString*) NoCopyString { return [[NSString alloc] init]; } // expected-warning{{leak}}
-- (NSString*) noCopyString { return [[NSString alloc] init]; } // expected-warning{{leak}}
- at end
-
-void test_RDar6859457(RDar6859457 *x, void *bytes, NSUInteger dataLength) {
- [x NoCopyString]; // expected-warning{{leak}}
- [x noCopyString]; // expected-warning{{leak}}
- [NSData dataWithBytesNoCopy:bytes length:dataLength]; // no-warning
- [NSData dataWithBytesNoCopy:bytes length:dataLength freeWhenDone:1]; // no-warning
-}
-
-//===----------------------------------------------------------------------===//
-// PR 4230 - an autorelease pool is not necessarily leaked during a premature
-// return
-//===----------------------------------------------------------------------===//
-
-static void PR4230(void)
-{
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; // no-warning
- NSString *object = [[[NSString alloc] init] autorelease]; // no-warning
- return;
-}
-
-static void PR4230_new(void)
-{
- NSAutoreleasePool *pool = [NSAutoreleasePool new]; // no-warning
- NSString *object = [[[NSString alloc] init] autorelease]; // no-warning
- return;
-}
-
-//===----------------------------------------------------------------------===//
-// Method name that has a null IdentifierInfo* for its first selector slot.
-// This test just makes sure that we handle it.
-//===----------------------------------------------------------------------===//
- at interface TestNullIdentifier
- at end
-
- at implementation TestNullIdentifier
-+ (id):(int)x, ... {
- return [[NSString alloc] init]; // expected-warning{{leak}}
-}
- at end
-
-//===----------------------------------------------------------------------===//
-// don't flag leaks for return types that cannot be determined to be CF types
-//===----------------------------------------------------------------------===//
-
-// We don't know if 'struct s6893565' represents a Core Foundation type, so
-// we shouldn't emit an error here.
-typedef struct s6893565* TD6893565;
-
- at interface RDar6893565 {}
--(TD6893565)newThing;
- at end
-
- at implementation RDar6893565
--(TD6893565)newThing {
- return (TD6893565) [[NSString alloc] init]; // no-warning
-}
- at end
-
-//===----------------------------------------------------------------------===//
-// clang: false positives w/QC and CoreImage methods
-//===----------------------------------------------------------------------===//
-void rdar6902710(QCView *view, QCRenderer *renderer, CIContext *context,
- NSString *str, CIImage *img, CGRect rect,
- CIFormat form, CGColorSpaceRef cs) {
- [view createSnapshotImageOfType:str]; // expected-warning{{leak}}
- [renderer createSnapshotImageOfType:str]; // expected-warning{{leak}}
- [context createCGImage:img fromRect:rect]; // expected-warning{{leak}}
- [context createCGImage:img fromRect:rect format:form colorSpace:cs]; // expected-warning{{leak}}
-}
-
-//===----------------------------------------------------------------------===//
-// -[CIContext createCGLayerWithSize:info:] misinterpreted by clang scan-build
-//===----------------------------------------------------------------------===//
-void rdar6945561(CIContext *context, CGSize size, CFDictionaryRef d) {
- [context createCGLayerWithSize:size info:d]; // expected-warning{{leak}}
-}
-
-//===----------------------------------------------------------------------===//
-// Add knowledge of IOKit functions to retain/release checker.
-//===----------------------------------------------------------------------===//
-void IOBSDNameMatching_wrapper(mach_port_t mainPort, uint32_t options, const char * bsdName) {
- IOBSDNameMatching(mainPort, options, bsdName); // expected-warning{{leak}}
-}
-
-void IOServiceMatching_wrapper(const char * name) {
- IOServiceMatching(name); // expected-warning{{leak}}
-}
-
-void IOServiceNameMatching_wrapper(const char * name) {
- IOServiceNameMatching(name); // expected-warning{{leak}}
-}
-
-CF_RETURNS_RETAINED CFDictionaryRef CreateDict(void);
-
-void IOServiceAddNotification_wrapper(mach_port_t mainPort, const io_name_t notificationType,
- mach_port_t wakePort, uintptr_t reference, io_iterator_t * notification ) {
-
- CFDictionaryRef matching = CreateDict();
- CFRelease(matching);
- IOServiceAddNotification(mainPort, notificationType, matching, // expected-warning{{used after it is released}} expected-warning{{deprecated}}
- wakePort, reference, notification);
-}
-
-void IORegistryEntryIDMatching_wrapper(uint64_t entryID ) {
- IORegistryEntryIDMatching(entryID); // expected-warning{{leak}}
-}
-
-void IOOpenFirmwarePathMatching_wrapper(mach_port_t mainPort, uint32_t options,
- const char * path) {
- IOOpenFirmwarePathMatching(mainPort, options, path); // expected-warning{{leak}}
-}
-
-void IOServiceGetMatchingService_wrapper(mach_port_t mainPort) {
- CFDictionaryRef matching = CreateDict();
- IOServiceGetMatchingService(mainPort, matching);
- CFRelease(matching); // expected-warning{{used after it is released}}
-}
-
-void IOServiceGetMatchingServices_wrapper(mach_port_t mainPort, io_iterator_t *existing) {
- CFDictionaryRef matching = CreateDict();
- IOServiceGetMatchingServices(mainPort, matching, existing);
- CFRelease(matching); // expected-warning{{used after it is released}}
-}
-
-void IOServiceAddMatchingNotification_wrapper(IONotificationPortRef notifyPort, const io_name_t notificationType,
- IOServiceMatchingCallback callback, void * refCon, io_iterator_t * notification) {
-
- CFDictionaryRef matching = CreateDict();
- IOServiceAddMatchingNotification(notifyPort, notificationType, matching, callback, refCon, notification);
- CFRelease(matching); // expected-warning{{used after it is released}}
-}
-
-//===----------------------------------------------------------------------===//
-// Test of handling objects whose references "escape" to containers.
-//===----------------------------------------------------------------------===//
-void CFDictionaryAddValue(CFMutableDictionaryRef, void *, void *);
-
-void rdar_6539791(CFMutableDictionaryRef y, void* key, void* val_key) {
- CFMutableDictionaryRef x = CFDictionaryCreateMutable(kCFAllocatorDefault, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
- CFDictionaryAddValue(y, key, x);
- CFRelease(x); // the dictionary keeps a reference, so the object isn't deallocated yet
- signed z = 1;
- CFNumberRef value = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &z);
- if (value) {
- CFDictionaryAddValue(x, val_key, (void*)value); // no-warning
- CFRelease(value);
- CFDictionaryAddValue(y, val_key, (void*)value); // no-warning
- }
-}
-
-// Same issue, except with "AppendValue" functions.
-void rdar_6560661(CFMutableArrayRef x) {
- signed z = 1;
- CFNumberRef value = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &z);
- // CFArrayAppendValue keeps a reference to value.
- CFArrayAppendValue(x, value);
- CFRelease(value);
- CFRetain(value);
- CFRelease(value); // no-warning
-}
-
-// Same issue, excwept with "CFAttributeStringSetAttribute".
-void rdar_7152619(CFStringRef str) {
- CFAttributedStringRef string = CFAttributedStringCreate(kCFAllocatorDefault, str, 0);
- CFMutableAttributedStringRef attrString = CFAttributedStringCreateMutableCopy(kCFAllocatorDefault, 100, string);
- CFRelease(string);
- NSNumber *number = [[NSNumber alloc] initWithInt:5]; // expected-warning{{leak}}
- CFAttributedStringSetAttribute(attrString, CFRangeMake(0, 1), str, number);
- [number release];
- [number retain];
- CFRelease(attrString);
-}
-
-//===----------------------------------------------------------------------===//
-// Test of handling CGGradientXXX functions.
-//===----------------------------------------------------------------------===//
-
-void rdar_7184450(CGContextRef myContext, CGFloat x, CGPoint myStartPoint,
- CGPoint myEndPoint) {
- size_t num_locations = 6;
- CGFloat locations[6] = { 0.0, 0.265, 0.28, 0.31, 0.36, 1.0 };
- CGFloat components[28] = { 239.0/256.0, 167.0/256.0, 170.0/256.0,
- x, // Start color
- 207.0/255.0, 39.0/255.0, 39.0/255.0, x,
- 147.0/255.0, 21.0/255.0, 22.0/255.0, x,
- 175.0/255.0, 175.0/255.0, 175.0/255.0, x,
- 255.0/255.0,255.0/255.0, 255.0/255.0, x,
- 255.0/255.0,255.0/255.0, 255.0/255.0, x
- }; // End color
-
- CGGradientRef myGradient =
- CGGradientCreateWithColorComponents(CGColorSpaceCreateDeviceRGB(), // expected-warning{{leak}}
- components, locations, num_locations);
-
- CGContextDrawLinearGradient(myContext, myGradient, myStartPoint, myEndPoint,
- 0);
- CGGradientRelease(myGradient);
-}
-
-void rdar_7184450_pos(CGContextRef myContext, CGFloat x, CGPoint myStartPoint,
- CGPoint myEndPoint) {
- size_t num_locations = 6;
- CGFloat locations[6] = { 0.0, 0.265, 0.28, 0.31, 0.36, 1.0 };
- CGFloat components[28] = { 239.0/256.0, 167.0/256.0, 170.0/256.0,
- x, // Start color
- 207.0/255.0, 39.0/255.0, 39.0/255.0, x,
- 147.0/255.0, 21.0/255.0, 22.0/255.0, x,
- 175.0/255.0, 175.0/255.0, 175.0/255.0, x,
- 255.0/255.0,255.0/255.0, 255.0/255.0, x,
- 255.0/255.0,255.0/255.0, 255.0/255.0, x
- }; // End color
-
- CGGradientRef myGradient =
- CGGradientCreateWithColorComponents(CGColorSpaceCreateDeviceRGB(), components, locations, num_locations); // expected-warning 2 {{leak}}
-
- CGContextDrawLinearGradient(myContext, myGradient, myStartPoint, myEndPoint,
- 0);
-}
-
-//===----------------------------------------------------------------------===//
-// clang false positive: retained instance passed to thread in pthread_create
-// marked as leak
-//
-// Until we have full IPA, the analyzer should stop tracking the reference
-// count of objects passed to pthread_create.
-//
-//===----------------------------------------------------------------------===//
-struct _opaque_pthread_t {};
-struct _opaque_pthread_attr_t {};
-typedef struct _opaque_pthread_t *__darwin_pthread_t;
-typedef struct _opaque_pthread_attr_t __darwin_pthread_attr_t;
-typedef __darwin_pthread_t pthread_t;
-typedef __darwin_pthread_attr_t pthread_attr_t;
-typedef unsigned long __darwin_pthread_key_t;
-typedef __darwin_pthread_key_t pthread_key_t;
-
-int pthread_create(pthread_t *, const pthread_attr_t *,
- void *(*)(void *), void *);
-
-int pthread_setspecific(pthread_key_t key, const void *value);
-
-void *rdar_7299394_start_routine(void *p) {
- [((id) p) release];
- return 0;
-}
-void rdar_7299394(pthread_attr_t *attr, pthread_t *thread, void *args) {
- NSNumber *number = [[NSNumber alloc] initWithInt:5]; // no-warning
- pthread_create(thread, attr, rdar_7299394_start_routine, number);
-}
-void rdar_7299394_positive(pthread_attr_t *attr, pthread_t *thread) {
- NSNumber *number = [[NSNumber alloc] initWithInt:5]; // expected-warning{{leak}}
-}
-
-//===----------------------------------------------------------------------===//
-// false positive with not understanding thread local storage
-//===----------------------------------------------------------------------===//
-void rdar11282706(pthread_key_t key) {
- NSNumber *number = [[NSNumber alloc] initWithInt:5]; // no-warning
- pthread_setspecific(key, (void*) number);
-}
-
-//===----------------------------------------------------------------------===//
-// False leak associated with call to CVPixelBufferCreateWithBytes ()
-//
-// According to the Core Video Reference (ADC), CVPixelBufferCreateWithBytes and
-// CVPixelBufferCreateWithPlanarBytes can release (via a callback) the
-// pixel buffer object. These test cases show how the analyzer stops tracking
-// the reference count for the objects passed for this argument. This
-// could be made smarter.
-//===----------------------------------------------------------------------===//
-typedef int int32_t;
-typedef UInt32 FourCharCode;
-typedef FourCharCode OSType;
-typedef uint64_t CVOptionFlags;
-typedef int32_t CVReturn;
-typedef struct __CVBuffer *CVBufferRef;
-typedef CVBufferRef CVImageBufferRef;
-typedef CVImageBufferRef CVPixelBufferRef;
-typedef void (*CVPixelBufferReleaseBytesCallback)( void *releaseRefCon, const void *baseAddress );
-
-extern CVReturn CVPixelBufferCreateWithBytes(CFAllocatorRef allocator,
- size_t width,
- size_t height,
- OSType pixelFormatType,
- void *baseAddress,
- size_t bytesPerRow,
- CVPixelBufferReleaseBytesCallback releaseCallback,
- void *releaseRefCon,
- CFDictionaryRef pixelBufferAttributes,
- CVPixelBufferRef *pixelBufferOut) ;
-
-typedef void (*CVPixelBufferReleasePlanarBytesCallback)( void *releaseRefCon, const void *dataPtr, size_t dataSize, size_t numberOfPlanes, const void *planeAddresses[] );
-
-extern CVReturn CVPixelBufferCreateWithPlanarBytes(CFAllocatorRef allocator,
- size_t width,
- size_t height,
- OSType pixelFormatType,
- void *dataPtr,
- size_t dataSize,
- size_t numberOfPlanes,
- void *planeBaseAddress[],
- size_t planeWidth[],
- size_t planeHeight[],
- size_t planeBytesPerRow[],
- CVPixelBufferReleasePlanarBytesCallback releaseCallback,
- void *releaseRefCon,
- CFDictionaryRef pixelBufferAttributes,
- CVPixelBufferRef *pixelBufferOut) ;
-
-extern CVReturn CVPixelBufferCreateWithBytes(CFAllocatorRef allocator,
- size_t width,
- size_t height,
- OSType pixelFormatType,
- void *baseAddress,
- size_t bytesPerRow,
- CVPixelBufferReleaseBytesCallback releaseCallback,
- void *releaseRefCon,
- CFDictionaryRef pixelBufferAttributes,
- CVPixelBufferRef *pixelBufferOut) ;
-
-CVReturn rdar_7283567(CFAllocatorRef allocator, size_t width, size_t height,
- OSType pixelFormatType, void *baseAddress,
- size_t bytesPerRow,
- CVPixelBufferReleaseBytesCallback releaseCallback,
- CFDictionaryRef pixelBufferAttributes,
- CVPixelBufferRef *pixelBufferOut) {
-
- // For the allocated object, it doesn't really matter what type it is
- // for the purpose of this test. All we want to show is that
- // this is freed later by the callback.
- NSNumber *number = [[NSNumber alloc] initWithInt:5]; // no-warning
-
- return CVPixelBufferCreateWithBytes(allocator, width, height, pixelFormatType,
- baseAddress, bytesPerRow, releaseCallback,
- number, // potentially released by callback
- pixelBufferAttributes, pixelBufferOut) ;
-}
-
-CVReturn rdar_7283567_2(CFAllocatorRef allocator, size_t width, size_t height,
- OSType pixelFormatType, void *dataPtr, size_t dataSize,
- size_t numberOfPlanes, void *planeBaseAddress[],
- size_t planeWidth[], size_t planeHeight[], size_t planeBytesPerRow[],
- CVPixelBufferReleasePlanarBytesCallback releaseCallback,
- CFDictionaryRef pixelBufferAttributes,
- CVPixelBufferRef *pixelBufferOut) {
-
- // For the allocated object, it doesn't really matter what type it is
- // for the purpose of this test. All we want to show is that
- // this is freed later by the callback.
- NSNumber *number = [[NSNumber alloc] initWithInt:5]; // no-warning
-
- return CVPixelBufferCreateWithPlanarBytes(allocator,
- width, height, pixelFormatType, dataPtr, dataSize,
- numberOfPlanes, planeBaseAddress, planeWidth,
- planeHeight, planeBytesPerRow, releaseCallback,
- number, // potentially released by callback
- pixelBufferAttributes, pixelBufferOut) ;
-}
-
-//===----------------------------------------------------------------------===//
-// False leak associated with CGBitmapContextCreateWithData
-//===----------------------------------------------------------------------===//
-typedef uint32_t CGBitmapInfo;
-typedef void (*CGBitmapContextReleaseDataCallback)(void *releaseInfo, void *data);
-
-CGContextRef CGBitmapContextCreateWithData(void *data,
- size_t width, size_t height, size_t bitsPerComponent,
- size_t bytesPerRow, CGColorSpaceRef space, CGBitmapInfo bitmapInfo,
- CGBitmapContextReleaseDataCallback releaseCallback, void *releaseInfo) CF_RETURNS_RETAINED;
-
-void rdar_7358899(void *data,
- size_t width, size_t height, size_t bitsPerComponent,
- size_t bytesPerRow, CGColorSpaceRef space, CGBitmapInfo bitmapInfo,
- CGBitmapContextReleaseDataCallback releaseCallback) {
-
- // For the allocated object, it doesn't really matter what type it is
- // for the purpose of this test. All we want to show is that
- // this is freed later by the callback.
- NSNumber *number = [[NSNumber alloc] initWithInt:5]; // no-warning
-
- CGBitmapContextCreateWithData(data, width, height, bitsPerComponent, // expected-warning{{leak}}
- bytesPerRow, space, bitmapInfo, releaseCallback, number);
-}
-
-//===----------------------------------------------------------------------===//
-// Allow 'new', 'copy', 'alloc', 'init' prefix to start before '_' when
-// determining Cocoa fundamental rule.
-//
-// Previously the retain/release checker just skipped prefixes before the
-// first '_' entirely. Now the checker honors the prefix if it results in a
-// recognizable naming convention (e.g., 'new', 'init').
-//===----------------------------------------------------------------------===//
- at interface RDar7265711 {}
-- (id) new_stuff;
- at end
-
-void rdar7265711_a(RDar7265711 *x) {
- id y = [x new_stuff]; // expected-warning{{leak}}
-}
-
-void rdar7265711_b(RDar7265711 *x) {
- id y = [x new_stuff]; // no-warning
- [y release];
-}
-
-//===----------------------------------------------------------------------===//
-// clang thinks [NSCursor dragCopyCursor] returns a retained reference
-//===----------------------------------------------------------------------===//
- at interface NSCursor : NSObject
-+ (NSCursor *)dragCopyCursor;
- at end
-
-void rdar7306898(void) {
- // 'dragCopyCursor' does not follow Cocoa's fundamental rule. It is a noun, not an sentence
- // implying a 'copy' of something.
- NSCursor *c = [NSCursor dragCopyCursor]; // no-warning
- NSNumber *number = [[NSNumber alloc] initWithInt:5]; // expected-warning{{leak}}
-}
-
-//===----------------------------------------------------------------------===//
-// Sending 'release', 'retain', etc. to a Class directly is not likely what the
-// user intended.
-//===----------------------------------------------------------------------===//
- at interface RDar7252064 : NSObject @end
-void rdar7252064(void) {
- [RDar7252064 release]; // expected-warning{{The 'release' message should be sent to instances of class 'RDar7252064' and not the class directly}}
- [RDar7252064 retain]; // expected-warning{{The 'retain' message should be sent to instances of class 'RDar7252064' and not the class directly}}
- [RDar7252064 autorelease]; // expected-warning{{The 'autorelease' message should be sent to instances of class 'RDar7252064' and not the class directly}}
- [NSAutoreleasePool drain]; // expected-warning{{method '+drain' not found}} expected-warning{{The 'drain' message should be sent to instances of class 'NSAutoreleasePool' and not the class directly}}
-}
-
-//===----------------------------------------------------------------------===//
-// Tests of ownership attributes.
-//===----------------------------------------------------------------------===//
-
-typedef NSString* MyStringTy;
-
- at protocol FooP;
-
- at interface TestOwnershipAttr : NSObject
-- (NSString*) returnsAnOwnedString NS_RETURNS_RETAINED; // no-warning
-- (NSString*) returnsAnOwnedCFString CF_RETURNS_RETAINED; // no-warning
-- (MyStringTy) returnsAnOwnedTypedString NS_RETURNS_RETAINED; // no-warning
-- (NSString*) newString NS_RETURNS_NOT_RETAINED; // no-warning
-- (NSString*) newString_auto NS_RETURNS_AUTORELEASED; // no-warning
-- (NSString*) newStringNoAttr;
-- (int) returnsAnOwnedInt NS_RETURNS_RETAINED; // expected-warning{{'ns_returns_retained' attribute only applies to methods that return an Objective-C object}}
-- (id) pseudoInit NS_CONSUMES_SELF NS_RETURNS_RETAINED;
-+ (void) consume:(id) NS_CONSUMED x;
-+ (void) consume2:(id) CF_CONSUMED x;
- at end
-
-static int ownership_attribute_doesnt_go_here NS_RETURNS_RETAINED; // expected-warning{{'ns_returns_retained' attribute only applies to functions and methods}}
-
-void test_attr_1(TestOwnershipAttr *X) {
- NSString *str = [X returnsAnOwnedString]; // expected-warning{{leak}}
-}
-
-void test_attr_1b(TestOwnershipAttr *X) {
- NSString *str = [X returnsAnOwnedCFString]; // expected-warning{{leak}}
-}
-
-void test_attr1c(TestOwnershipAttr *X) {
- NSString *str = [X newString]; // no-warning
- NSString *str2 = [X newStringNoAttr]; // expected-warning{{leak}}
- NSString *str3 = [X newString_auto]; // no-warning
- NSString *str4 = [[X newString_auto] retain]; // expected-warning {{leak}}
-}
-
-void testattr2_a(void) {
- TestOwnershipAttr *x = [TestOwnershipAttr alloc]; // expected-warning{{leak}}
-}
-
-void testattr2_b(void) {
- TestOwnershipAttr *x = [[TestOwnershipAttr alloc] pseudoInit]; // expected-warning{{leak}}
-}
-
-void testattr2_b_11358224_self_assign_looses_the_leak(void) {
- TestOwnershipAttr *x = [[TestOwnershipAttr alloc] pseudoInit];// expected-warning{{leak}}
- x = x;
-}
-
-void testattr2_c(void) {
- TestOwnershipAttr *x = [[TestOwnershipAttr alloc] pseudoInit]; // no-warning
- [x release];
-}
-
-void testattr3(void) {
- TestOwnershipAttr *x = [TestOwnershipAttr alloc]; // no-warning
- [TestOwnershipAttr consume:x];
- TestOwnershipAttr *y = [TestOwnershipAttr alloc]; // no-warning
- [TestOwnershipAttr consume2:y];
-}
-
-void consume_ns(id NS_CONSUMED x);
-void consume_cf(id CF_CONSUMED x);
-
-void testattr4(void) {
- TestOwnershipAttr *x = [TestOwnershipAttr alloc]; // no-warning
- consume_ns(x);
- TestOwnershipAttr *y = [TestOwnershipAttr alloc]; // no-warning
- consume_cf(y);
-}
-
- at interface TestOwnershipAttr2 : NSObject
-- (NSString*) newString NS_RETURNS_NOT_RETAINED; // no-warning
- at end
-
- at implementation TestOwnershipAttr2
-- (NSString*) newString {
- return [NSString alloc]; // expected-warning {{Potential leak of an object}}
-}
- at end
-
- at interface MyClassTestCFAttr : NSObject {}
-- (NSDate*) returnsCFRetained CF_RETURNS_RETAINED;
-- (CFDateRef) returnsCFRetainedAsCF CF_RETURNS_RETAINED;
-- (CFDateRef) newCFRetainedAsCF CF_RETURNS_NOT_RETAINED;
-- (CFDateRef) newCFRetainedAsCFNoAttr CF_RETURNS_RETAINED;
-- (NSDate*) alsoReturnsRetained;
-- (CFDateRef) alsoReturnsRetainedAsCF CF_RETURNS_NOT_RETAINED;
-- (NSDate*) returnsNSRetained NS_RETURNS_RETAINED;
- at end
-
-CF_RETURNS_RETAINED
-CFDateRef returnsRetainedCFDate(void) {
- return CFDateCreate(0, CFAbsoluteTimeGetCurrent());
-}
-
- at implementation MyClassTestCFAttr
-- (NSDate*) returnsCFRetained {
- return (NSDate*) returnsRetainedCFDate(); // No leak.
-}
-
-- (CFDateRef) returnsCFRetainedAsCF {
- return returnsRetainedCFDate(); // No leak.
-}
-
-- (CFDateRef) newCFRetainedAsCF {
- return (CFDateRef)[(id)[self returnsCFRetainedAsCF] autorelease];
-}
-
-- (CFDateRef) newCFRetainedAsCFNoAttr {
- return (CFDateRef)[(id)[self returnsCFRetainedAsCF] autorelease]; // expected-warning{{Object with a +0 retain count returned to caller where a +1 (owning) retain count is expected}}
-}
-
-- (NSDate*) alsoReturnsRetained {
- return (NSDate*) returnsRetainedCFDate(); // expected-warning{{leak}}
-}
-
-- (CFDateRef) alsoReturnsRetainedAsCF {
- return returnsRetainedCFDate(); // expected-warning{{leak}}
-}
-
-
-- (NSDate*) returnsNSRetained {
- return (NSDate*) returnsRetainedCFDate(); // no-warning
-}
- at end
-
-//===----------------------------------------------------------------------===//
-// Test that leaks post-dominated by "panic" functions are not reported.
-//
-// Do not report a leak when post-dominated by a call to a noreturn or panic
-// function.
-//===----------------------------------------------------------------------===//
-void panic(void) __attribute__((noreturn));
-void panic_not_in_hardcoded_list(void) __attribute__((noreturn));
-
-void test_panic_negative(void) {
- signed z = 1;
- CFNumberRef value = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &z); // expected-warning{{leak}}
-}
-
-void test_panic_positive(void) {
- signed z = 1;
- CFNumberRef value = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &z); // no-warning
- panic();
-}
-
-void test_panic_neg_2(int x) {
- signed z = 1;
- CFNumberRef value = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &z); // expected-warning{{leak}}
- if (x)
- panic();
-}
-
-void test_panic_pos_2(int x) {
- signed z = 1;
- CFNumberRef value = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &z); // no-warning
- if (x)
- panic();
- if (!x) {
- // This showed up previously where we silently missed checking the function
- // type for noreturn. "panic()" is a hard-coded known panic function that
- // isn't always noreturn.
- panic_not_in_hardcoded_list();
- }
-}
-
-//===----------------------------------------------------------------------===//
-// Test uses of blocks (closures)
-//===----------------------------------------------------------------------===//
-
-void test_blocks_1_pos(void) {
- NSNumber *number = [[NSNumber alloc] initWithInt:5]; // expected-warning{{leak}}
- ^{}();
-}
-
-void test_blocks_1_indirect_release(void) {
- NSNumber *number = [[NSNumber alloc] initWithInt:5]; // no-warning
- ^{ [number release]; }();
-}
-
-void test_blocks_1_indirect_retain(void) {
- // Eventually this should be reported as a leak.
- NSNumber *number = [[NSNumber alloc] initWithInt:5]; // no-warning
- ^{ [number retain]; }();
-}
-
-void test_blocks_1_indirect_release_via_call(void) {
- NSNumber *number = [[NSNumber alloc] initWithInt:5]; // no-warning
- ^(NSObject *o){ [o release]; }(number);
-}
-
-void test_blocks_1_indirect_retain_via_call(void) {
- NSNumber *number = [[NSNumber alloc] initWithInt:5]; // expected-warning {{leak}}
- ^(NSObject *o){ [o retain]; }(number);
-}
-
-//===--------------------------------------------------------------------===//
-// Test sending message to super that returns an object alias. Previously
-// this caused a crash in the analyzer.
-//===--------------------------------------------------------------------===//
-
- at interface Rdar8015556 : NSObject {} @end
- at implementation Rdar8015556
-- (id)retain {
- return [super retain];
-}
- at end
-
-// Correcly handle Class<...> in Cocoa Conventions detector.
- at protocol Prot_R8272168 @end
-Class <Prot_R8272168> GetAClassThatImplementsProt_R8272168(void);
-void r8272168(void) {
- GetAClassThatImplementsProt_R8272168();
-}
-
-// Test case which in the past triggered a false positive.
- at interface RDar8356342
-- (NSDate*) rdar8356342:(NSDate *)inValue;
- at end
-
- at implementation RDar8356342
-- (NSDate*) rdar8356342:(NSDate*)inValue {
- NSDate *outValue = inValue;
- if (outValue == 0)
- outValue = [[NSDate alloc] init]; // no-warning
-
- if (outValue != inValue)
- [outValue autorelease];
-
- return outValue;
-}
- at end
-
-// This test case previously crashed because of a bug in BugReporter.
-extern const void *CFDictionaryGetValue(CFDictionaryRef theDict, const void *key) CF_RETURNS_NOT_RETAINED;
-typedef struct __CFError * CFErrorRef;
-extern const CFStringRef kCFErrorUnderlyingErrorKey;
-extern CFDictionaryRef CFErrorCopyUserInfo(CFErrorRef err) CF_RETURNS_RETAINED;
-static void rdar_8724287(CFErrorRef error)
-{
- CFErrorRef error_to_dump;
-
- error_to_dump = error;
- while (error_to_dump != ((void*)0)) {
- CFDictionaryRef info;
-
- info = CFErrorCopyUserInfo(error_to_dump); // expected-warning{{Potential leak of an object}}
-
- if (info != ((void*)0)) {
- }
-
- error_to_dump = (CFErrorRef) CFDictionaryGetValue(info, kCFErrorUnderlyingErrorKey);
- }
-}
-
-// Make sure the model applies cf_consumed correctly in argument positions
-// besides the first.
-
-CF_IMPLICIT_BRIDGING_ENABLED
-
-extern void *CFStringCreate(void);
-
-CF_IMPLICIT_BRIDGING_DISABLED
-
-extern void rdar_9234108_helper(void *key, void * CF_CONSUMED value);
-void rdar_9234108(void) {
- rdar_9234108_helper(0, CFStringCreate());
-}
-
-// Make sure that objc_method_family works to override naming conventions.
-struct TwoDoubles {
- double one;
- double two;
-};
-typedef struct TwoDoubles TwoDoubles;
-
- at interface NSValue (Mine)
-- (id)_prefix_initWithTwoDoubles:(TwoDoubles)twoDoubles __attribute__((objc_method_family(init)));
- at end
-
- at implementation NSValue (Mine)
-- (id)_prefix_initWithTwoDoubles:(TwoDoubles)twoDoubles
-{
- return [self init];
-}
- at end
-
-void rdar9726279(void) {
- TwoDoubles twoDoubles = { 0.0, 0.0 };
- NSValue *value = [[NSValue alloc] _prefix_initWithTwoDoubles:twoDoubles];
- [value release];
-}
-
-// Test camelcase support for CF conventions. While Core Foundation APIs
-// don't use camel casing, other code is allowed to use it.
-CFArrayRef camelcase_create_1(void) {
- return CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // no-warning
-}
-
-CFArrayRef camelcase_createno(void) {
- return CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // expected-warning {{leak}}
-}
-
-CFArrayRef camelcase_copy(void) {
- return CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // no-warning
-}
-
-CFArrayRef camelcase_copying(void) {
- return CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // expected-warning {{leak}}
-}
-
-CFArrayRef copyCamelCase(void) {
- return CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // no-warning
-}
-
-CFArrayRef __copyCamelCase(void) {
- return CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // no-warning
-}
-
-CFArrayRef __createCamelCase(void) {
- return CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // no-warning
-}
-
-CFArrayRef camel_create(void) {
- return CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // no-warning
-}
-
-
-CFArrayRef camel_creat(void) {
- return CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // expected-warning {{leak}}
-}
-
-CFArrayRef camel_copy(void) {
- return CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // no-warning
-}
-
-CFArrayRef camel_copyMachine(void) {
- return CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // no-warning
-}
-
-CFArrayRef camel_copymachine(void) {
- return CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // expected-warning {{leak}}
-}
-
- at protocol F18P
-- (id) clone;
- at end
- at interface F18 : NSObject<F18P> @end
- at interface F18(Cat)
-- (id) clone NS_RETURNS_RETAINED;
- at end
-
- at implementation F18
-- (id) clone {
- return [F18 alloc];
-}
- at end
-
-void rdar6582778(void) {
- CFAbsoluteTime t = CFAbsoluteTimeGetCurrent();
- CFTypeRef vals[] = { CFDateCreate(0, t) }; // expected-warning {{leak}}
-}
-
-CFTypeRef global;
-
-void rdar6582778_2(void) {
- CFAbsoluteTime t = CFAbsoluteTimeGetCurrent();
- global = CFDateCreate(0, t); // no-warning
-}
-
-// Test that objects passed to containers are marked "escaped".
-void rdar10232019(void) {
- NSMutableArray *array = [NSMutableArray array];
-
- NSString *string = [[NSString alloc] initWithUTF8String:"foo"];
- [array addObject:string];
- [string release];
-
- NSString *otherString = [string stringByAppendingString:@"bar"]; // no-warning
- NSLog(@"%@", otherString);
-}
-
-void rdar10232019_positive(void) {
- NSMutableArray *array = [NSMutableArray array];
-
- NSString *string = [[NSString alloc] initWithUTF8String:"foo"];
- [string release];
-
- NSString *otherString = [string stringByAppendingString:@"bar"]; // expected-warning {{Reference-counted object is used after it is release}}
- NSLog(@"%@", otherString);
-}
-
-// RetainCountChecker support for XPC.
-typedef void * xpc_object_t;
-xpc_object_t _CFXPCCreateXPCObjectFromCFObject(CFTypeRef cf);
-void xpc_release(xpc_object_t object);
-
-void rdar9658496(void) {
- CFStringRef cf;
- xpc_object_t xpc;
- cf = CFStringCreateWithCString( ((CFAllocatorRef)0), "test", kCFStringEncodingUTF8 ); // no-warning
- xpc = _CFXPCCreateXPCObjectFromCFObject( cf );
- CFRelease(cf);
- xpc_release(xpc);
-}
-
-// Support annotations with method families.
- at interface RDar10824732 : NSObject
-- (instancetype)initWithObj:(id CF_CONSUMED)obj;
- at end
-
- at implementation RDar10824732
-- (instancetype)initWithObj:(id)obj {
- [obj release];
- return [super init];
-}
- at end
-
-void rdar_10824732(void) {
- @autoreleasepool {
- NSString *obj = @"test";
- RDar10824732 *foo = [[RDar10824732 alloc] initWithObj:obj]; // no-warning
- [foo release];
- }
-}
-
-// Stop tracking objects passed to functions, which take callbacks as parameters.
-typedef int (*CloseCallback) (void *);
-void ReaderForIO(CloseCallback ioclose, void *ioctx);
-int IOClose(void *context);
-
- at protocol SInS <NSObject>
- at end
-
- at interface radar10973977 : NSObject
-- (id<SInS>)inputS;
-- (void)reader;
- at end
-
- at implementation radar10973977
-- (void)reader
-{
- id<SInS> inputS = [[self inputS] retain];
- ReaderForIO(IOClose, inputS);
-}
-- (id<SInS>)inputS
-{
- return 0;
-}
- at end
-
-// Object escapes through a selector callback
-extern id NSApp;
- at interface MySheetController
-- (id<SInS>)inputS;
-- (void)showDoSomethingSheetAction:(id)action;
-- (void)sheetDidEnd:(NSWindow *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo;
- at end
-
- at implementation MySheetController
-- (id<SInS>)inputS {
- return 0;
-}
-- (void)showDoSomethingSheetAction:(id)action {
- id<SInS> inputS = [[self inputS] retain];
- [NSApp beginSheet:0
- modalForWindow:0
- modalDelegate:0
- didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:)
- contextInfo:(void *)inputS]; // no - warning
-}
-- (void)sheetDidEnd:(NSWindow *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo {
-
- id contextObject = (id)contextInfo;
- [contextObject release];
-}
-
-- (id)copyAutoreleaseRadar13081402 {
- id x = [[[NSString alloc] initWithUTF8String:"foo"] autorelease];
- [x retain];
- return x; // no warning
-}
-
- at end
-//===----------------------------------------------------------------------===//
-// Test returning allocated memory in a struct.
-//
-// We currently don't have a general way to track pointers that "escape".
-// Here we test that RetainCountChecker doesn't get excited about returning
-// allocated CF objects in struct fields.
-//===----------------------------------------------------------------------===//
-void *malloc(size_t);
-struct rdar11104566 { CFStringRef myStr; };
-struct rdar11104566 test_rdar11104566(void) {
- CFStringRef cf = CFStringCreateWithCString( ((CFAllocatorRef)0), "test", kCFStringEncodingUTF8 ); // no-warning
- struct rdar11104566 V;
- V.myStr = cf;
- return V; // no-warning
-}
-
-struct rdar11104566 *test_2_rdar11104566(void) {
- CFStringRef cf = CFStringCreateWithCString( ((CFAllocatorRef)0), "test", kCFStringEncodingUTF8 ); // no-warning
- struct rdar11104566 *V = (struct rdar11104566 *) malloc(sizeof(*V));
- V->myStr = cf;
- return V; // no-warning
-}
-
-//===----------------------------------------------------------------------===//
-// ObjC literals support.
-//===----------------------------------------------------------------------===//
-
-void test_objc_arrays(void) {
- { // CASE ONE -- OBJECT IN ARRAY CREATED DIRECTLY
- NSObject *o = [[NSObject alloc] init];
- NSArray *a = [[NSArray alloc] initWithObjects:o, (void*)0]; // expected-warning {{leak}}
- [o release];
- [a description];
- [o description];
- }
-
- { // CASE TWO -- OBJECT IN ARRAY CREATED BY DUPING AUTORELEASED ARRAY
- NSObject *o = [[NSObject alloc] init];
- NSArray *a1 = [NSArray arrayWithObjects:o, (void*)0];
- NSArray *a2 = [[NSArray alloc] initWithArray:a1]; // expected-warning {{leak}}
- [o release];
- [a2 description];
- [o description];
- }
-
- { // CASE THREE -- OBJECT IN RETAINED @[]
- NSObject *o = [[NSObject alloc] init];
- NSArray *a3 = [@[o] retain]; // expected-warning {{leak}}
- [o release];
- [a3 description];
- [o description];
- }
-
- { // CASE FOUR -- OBJECT IN ARRAY CREATED BY DUPING @[]
- NSObject *o = [[NSObject alloc] init];
- NSArray *a = [[NSArray alloc] initWithArray:@[o]]; // expected-warning {{leak}}
- [o release];
-
- [a description];
- [o description];
- }
-
- { // CASE FIVE -- OBJECT IN RETAINED @{}
- NSValue *o = [[NSValue alloc] init];
- NSDictionary *a = [@{o : o} retain]; // expected-warning {{leak}}
- [o release];
-
- [a description];
- [o description];
- }
-}
-
-void test_objc_integer_literals(void) {
- id value = [@1 retain]; // expected-warning {{leak}}
- [value description];
-}
-
-void test_objc_boxed_expressions(int x, const char *y) {
- id value = [@(x) retain]; // expected-warning {{leak}}
- [value description];
-
- value = [@(y) retain]; // expected-warning {{leak}}
- [value description];
-}
-
-// Test NSLog doesn't escape tracked objects.
-void rdar11400885(int y)
-{
- @autoreleasepool {
- NSString *printString;
- if(y > 2)
- printString = [[NSString alloc] init];
- else
- printString = [[NSString alloc] init];
- NSLog(@"Once %@", printString);
- [printString release];
- NSLog(@"Again: %@", printString); // expected-warning {{Reference-counted object is used after it is released}}
- }
-}
-
-id makeCollectableNonLeak(void) {
- extern CFTypeRef CFCreateSomething(void);
-
- CFTypeRef object = CFCreateSomething(); // +1
- CFRetain(object); // +2
- id objCObject = NSMakeCollectable(object); // +2
- [objCObject release]; // +1
- return [objCObject autorelease]; // +0
-}
-
-
-void consumeAndStopTracking(id NS_CONSUMED obj, void (^callback)(void));
-void CFConsumeAndStopTracking(CFTypeRef CF_CONSUMED obj, void (^callback)(void));
-
-void testConsumeAndStopTracking(void) {
- id retained = [@[] retain]; // +1
- consumeAndStopTracking(retained, ^{}); // no-warning
-
- id doubleRetained = [[@[] retain] retain]; // +2
- consumeAndStopTracking(doubleRetained, ^{
- [doubleRetained release];
- }); // no-warning
-
- id unretained = @[]; // +0
- consumeAndStopTracking(unretained, ^{}); // expected-warning {{Incorrect decrement of the reference count of an object that is not owned at this point by the caller}}
-}
-
-void testCFConsumeAndStopTracking(void) {
- id retained = [@[] retain]; // +1
- CFConsumeAndStopTracking((CFTypeRef)retained, ^{}); // no-warning
-
- id doubleRetained = [[@[] retain] retain]; // +2
- CFConsumeAndStopTracking((CFTypeRef)doubleRetained, ^{
- [doubleRetained release];
- }); // no-warning
-
- id unretained = @[]; // +0
- CFConsumeAndStopTracking((CFTypeRef)unretained, ^{}); // expected-warning {{Incorrect decrement of the reference count of an object that is not owned at this point by the caller}}
-}
-//===----------------------------------------------------------------------===//
-// Test 'pragma clang arc_cf_code_audited' support.
-//===----------------------------------------------------------------------===//
-
-typedef void *MyCFType;
-#pragma clang arc_cf_code_audited begin
-MyCFType CreateMyCFType(void);
-#pragma clang arc_cf_code_audited end
-
-void test_custom_cf(void) {
- MyCFType x = CreateMyCFType(); // expected-warning {{leak of an object stored into 'x'}}
-}
-
-//===----------------------------------------------------------------------===//
-// Test calling CFPlugInInstanceCreate, which appears in CF but doesn't
-// return a CF object.
-//===----------------------------------------------------------------------===//
-
-void test_CFPlugInInstanceCreate(CFUUIDRef factoryUUID, CFUUIDRef typeUUID) {
- CFPlugInInstanceCreate(kCFAllocatorDefault, factoryUUID, typeUUID); // no-warning
-}
-
-//===----------------------------------------------------------------------===//
-// PR14927: -drain only has retain-count semantics on NSAutoreleasePool.
-//===----------------------------------------------------------------------===//
-
- at interface PR14927 : NSObject
-- (void)drain;
- at end
-
-void test_drain(void) {
- PR14927 *obj = [[PR14927 alloc] init];
- [obj drain];
- [obj release]; // no-warning
-}
-
-//===----------------------------------------------------------------------===//
-// Allow cf_returns_retained and cf_returns_not_retained to mark a return
-// value as tracked, even if the object isn't a known CF type.
-//===----------------------------------------------------------------------===//
-
-MyCFType getCustom(void) __attribute__((cf_returns_not_retained));
-MyCFType makeCustom(void) __attribute__((cf_returns_retained));
-
-void testCustomReturnsRetained(void) {
- MyCFType obj = makeCustom(); // expected-warning {{leak of an object stored into 'obj'}}
-}
-
-void testCustomReturnsNotRetained(void) {
- CFRelease(getCustom()); // expected-warning {{Incorrect decrement of the reference count of an object that is not owned at this point by the caller}}
-}
-
-//===----------------------------------------------------------------------===//
-// Don't print variables which are out of the current scope.
-//===----------------------------------------------------------------------===//
- at interface MyObj12706177 : NSObject
--(instancetype)initX;
-+(void)test12706177;
- at end
-static int Cond;
- at implementation MyObj12706177
--(instancetype)initX {
- if (Cond)
- return 0;
- self = [super init];
- return self;
-}
-+(void)test12706177 {
- id x = [[MyObj12706177 alloc] initX]; //expected-warning {{Potential leak of an object}}
- [x release];
-}
- at end
-
-//===----------------------------------------------------------------------===//
-// xpc_connection_set_finalizer_f
-//===----------------------------------------------------------------------===//
-typedef xpc_object_t xpc_connection_t;
-typedef void (*xpc_finalizer_t)(void *value);
-void xpc_connection_set_context(xpc_connection_t connection, void *ctx);
-void xpc_connection_set_finalizer_f(xpc_connection_t connection,
- xpc_finalizer_t finalizer);
-void releaseAfterXPC(void *context) {
- [(NSArray *)context release];
-}
-
-void rdar13783514(xpc_connection_t connection) {
- xpc_connection_set_context(connection, [[NSMutableArray alloc] init]);
- xpc_connection_set_finalizer_f(connection, releaseAfterXPC);
-} // no-warning
-
-CFAttributedStringRef CFAttributedCreate(void *CFObj CF_CONSUMED) CF_RETURNS_RETAINED;
-
- at interface Action
- at property (nonatomic) SEL action;
- at property (nonatomic, assign) id target;
- at end
diff --git a/clang/test/ARCMT/objcmt-atomic-property.m b/clang/test/ARCMT/objcmt-atomic-property.m
deleted file mode 100644
index 00b5e09c8e084c..00000000000000
--- a/clang/test/ARCMT/objcmt-atomic-property.m
+++ /dev/null
@@ -1,227 +0,0 @@
-// RUN: rm -rf %t
-// RUN: %clang_cc1 -fblocks -objcmt-migrate-readwrite-property -objcmt-migrate-readonly-property -objcmt-atomic-property -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11
-// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result
-// RUN: %clang_cc1 -fblocks -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c -fobjc-runtime-has-weak -fobjc-arc %s.result
-
-#define WEBKIT_OBJC_METHOD_ANNOTATION(ANNOTATION) ANNOTATION
-#define WEAK_IMPORT_ATTRIBUTE __attribute__((objc_arc_weak_reference_unavailable))
-#define AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER
-#define DEPRECATED __attribute__((deprecated))
-
-typedef char BOOL;
- at class NSString;
- at protocol NSCopying @end
-
- at interface NSObject <NSCopying>
- at end
-
- at interface NSDictionary : NSObject
- at end
-
- at interface I : NSObject {
- int ivarVal;
-}
-- (void) setWeakProp : (NSString *__weak)Val;
-- (NSString *__weak) WeakProp;
-
-- (NSString *) StrongProp;
-- (void) setStrongProp : (NSString *)Val;
-
-- (NSString *) UnavailProp __attribute__((unavailable));
-- (void) setUnavailProp : (NSString *)Val;
-
-- (NSString *) UnavailProp1 __attribute__((unavailable));
-- (void) setUnavailProp1 : (NSString *)Val __attribute__((unavailable));
-
-- (NSString *) UnavailProp2;
-- (void) setUnavailProp2 : (NSString *)Val __attribute__((unavailable));
-
-- (NSDictionary*) undoAction;
-- (void) setUndoAction: (NSDictionary*)Arg;
- at end
-
- at implementation I
- at end
-
- at class NSArray;
-
- at interface MyClass2 {
- at private
- NSArray *_names1;
- NSArray *_names2;
- NSArray *_names3;
- NSArray *_names4;
-}
-- (void)setNames1:(NSArray *)names;
-- (void)setNames4:(__strong NSArray *)names;
-- (void)setNames3:(__strong NSArray *)names;
-- (void)setNames2:(NSArray *)names;
-- (NSArray *) names2;
-- (NSArray *)names3;
-- (__strong NSArray *)names4;
-- (NSArray *) names1;
- at end
-
-// Properties that contain the name "delegate" or "dataSource",
-// or have exact name "target" have unsafe_unretained attribute.
- at interface NSInvocation
-- (id)target;
-- (void)setTarget:(id)target;
-
-- (id) dataSource;
-
-- (id)xxxdelegateYYY;
-- (void)setXxxdelegateYYY:(id)delegate;
-
-- (void)setDataSource:(id)source;
-
-- (id)MYtarget;
-- (void)setMYtarget: (id)target;
-
-- (id)targetX;
-- (void)setTargetX: (id)t;
-
-- (int)value;
-- (void)setValue: (int)val;
-
--(BOOL) isContinuous;
--(void) setContinuous:(BOOL)value;
-
-- (id) isAnObject;
-- (void)setAnObject : (id) object;
-
-- (BOOL) isinValid;
-- (void) setInValid : (BOOL) arg;
-
-- (void) Nothing;
-- (int) Length;
-- (id) object;
-+ (double) D;
-- (void *)JSObject WEBKIT_OBJC_METHOD_ANNOTATION(AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER);
-- (BOOL)isIgnoringInteractionEvents;
-
-- (NSString *)getStringValue;
-- (BOOL)getCounterValue;
-- (void)setStringValue:(NSString *)stringValue AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER;
-- (NSDictionary *)getns_dixtionary;
-
-- (BOOL)is3bar; // watch out
-- (NSString *)get3foo; // watch out
-
-- (BOOL) getM;
-- (BOOL) getMA;
-- (BOOL) getALL;
-- (BOOL) getMANY;
-- (BOOL) getSome;
- at end
-
-
- at interface NSInvocation(CAT)
-- (id)target;
-- (void)setTarget:(id)target;
-
-- (id) dataSource;
-
-- (id)xxxdelegateYYY;
-- (void)setXxxdelegateYYY:(id)delegate;
-
-- (void)setDataSource:(id)source;
-
-- (id)MYtarget;
-- (void)setMYtarget: (id)target;
-
-- (id)targetX;
-- (void)setTargetX: (id)t;
-
-- (int)value;
-- (void)setValue: (int)val;
-
--(BOOL) isContinuous;
--(void) setContinuous:(BOOL)value;
-
-- (id) isAnObject;
-- (void)setAnObject : (id) object;
-
-- (BOOL) isinValid;
-- (void) setInValid : (BOOL) arg;
-
-- (void) Nothing;
-- (int) Length;
-- (id) object;
-+ (double) D;
-
-- (BOOL)is3bar; // watch out
-- (NSString *)get3foo; // watch out
-
-- (BOOL) getM;
-- (BOOL) getMA;
-- (BOOL) getALL;
-- (BOOL) getMANY;
-- (BOOL) getSome;
- at end
-
-DEPRECATED
- at interface I_DEP
-- (BOOL) isinValid;
-- (void) setInValid : (BOOL) arg;
- at end
-
- at interface AnotherOne
-- (BOOL) isinValid DEPRECATED;
-- (void) setInValid : (BOOL) arg;
-- (id)MYtarget;
-- (void)setMYtarget: (id)target DEPRECATED;
-- (BOOL) getM DEPRECATED;
-
-- (id)xxxdelegateYYY DEPRECATED;
-- (void)setXxxdelegateYYY:(id)delegate DEPRECATED;
- at end
-
-#define NS_AVAILABLE __attribute__((availability(macosx,introduced=10.0)))
-#define NORETURN __attribute__((noreturn))
-#define ALIGNED __attribute__((aligned(16)))
-
- at interface NSURL
-// Do not infer a property.
-- (NSURL *)appStoreReceiptURL NS_AVAILABLE;
-- (void) setAppStoreReceiptURL : (NSURL *)object;
-
-- (NSURL *)appStoreReceiptURLX NS_AVAILABLE;
-- (void) setAppStoreReceiptURLX : (NSURL *)object NS_AVAILABLE;
-
-// Do not infer a property.
-- (NSURL *)appStoreReceiptURLY ;
-- (void) setAppStoreReceiptURLY : (NSURL *)object NS_AVAILABLE;
-
-- (id)OkToInfer NS_AVAILABLE;
-
-// Do not infer a property.
-- (NSURL *)appStoreReceiptURLZ ;
-- (void) setAppStoreReceiptURLZ : (NSURL *)object NS_AVAILABLE;
-
-// Do not infer a property.
-- (id) t1 NORETURN NS_AVAILABLE;
-- (void) setT1 : (id) arg NS_AVAILABLE;
-
-- (id)method1 ALIGNED NS_AVAILABLE;
-- (void) setMethod1 : (id) object NS_AVAILABLE ALIGNED;
-
-- (NSURL *)init; // No Change
-+ (id)alloc; // No Change
-
-- (BOOL)is1stClass; // Not a valid property
-- (BOOL)isClass; // This is a valid property 'class' is not a keyword in ObjC
-- (BOOL)isDouble; // Not a valid property
-
- at end
-
- at class NSMutableDictionary;
-
- at interface NSArray
-- (id (^)(id, NSArray *, NSMutableDictionary *)) expressionBlock;
-- (id (^)(id, NSArray *, NSMutableDictionary *)) MyBlock;
-- (void) setMyBlock : (id (^)(id, NSArray *, NSMutableDictionary *)) bl;
-- (id (*)(id, NSArray *, NSMutableDictionary *)) expressionFuncptr;
-- (id (*)(id, NSArray *, NSMutableDictionary *)) MyFuncptr;
-- (void) setMyFuncptr : (id (*)(id, NSArray *, NSMutableDictionary *)) bl;
- at end
diff --git a/clang/test/ARCMT/objcmt-atomic-property.m.result b/clang/test/ARCMT/objcmt-atomic-property.m.result
deleted file mode 100644
index c829a7aacb50d0..00000000000000
--- a/clang/test/ARCMT/objcmt-atomic-property.m.result
+++ /dev/null
@@ -1,200 +0,0 @@
-// RUN: rm -rf %t
-// RUN: %clang_cc1 -fblocks -objcmt-migrate-readwrite-property -objcmt-migrate-readonly-property -objcmt-atomic-property -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11
-// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result
-// RUN: %clang_cc1 -fblocks -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c -fobjc-runtime-has-weak -fobjc-arc %s.result
-
-#define WEBKIT_OBJC_METHOD_ANNOTATION(ANNOTATION) ANNOTATION
-#define WEAK_IMPORT_ATTRIBUTE __attribute__((objc_arc_weak_reference_unavailable))
-#define AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER
-#define DEPRECATED __attribute__((deprecated))
-
-typedef char BOOL;
- at class NSString;
- at protocol NSCopying @end
-
- at interface NSObject <NSCopying>
- at end
-
- at interface NSDictionary : NSObject
- at end
-
- at interface I : NSObject {
- int ivarVal;
-}
- at property (weak) NSString *WeakProp;
-
- at property (strong) NSString *StrongProp;
-
- at property (strong) NSString *UnavailProp __attribute__((unavailable));
-- (void) setUnavailProp : (NSString *)Val;
-
- at property (strong) NSString *UnavailProp1 __attribute__((unavailable));
-
- at property (strong) NSString *UnavailProp2;
-- (void) setUnavailProp2 : (NSString *)Val __attribute__((unavailable));
-
- at property (copy) NSDictionary *undoAction;
- at end
-
- at implementation I
- at end
-
- at class NSArray;
-
- at interface MyClass2 {
- at private
- NSArray *_names1;
- NSArray *_names2;
- NSArray *_names3;
- NSArray *_names4;
-}
- at property (strong) NSArray *names2;
- at property (strong) NSArray *names3;
- at property (strong) NSArray *names4;
- at property (strong) NSArray *names1;
- at end
-
-// Properties that contain the name "delegate" or "dataSource",
-// or have exact name "target" have unsafe_unretained attribute.
- at interface NSInvocation
- at property (assign) id target;
-
- at property (assign) id dataSource;
-
- at property (assign) id xxxdelegateYYY;
-
-
- at property (strong) id MYtarget;
-
- at property (strong) id targetX;
-
- at property int value;
-
- at property (getter=isContinuous) BOOL continuous;
-
-- (id) isAnObject;
-- (void)setAnObject : (id) object;
-
- at property (getter=isinValid, readonly) BOOL inValid;
-- (void) setInValid : (BOOL) arg;
-
-- (void) Nothing;
- at property (readonly) int Length;
- at property (readonly, strong) id object;
-+ (double) D;
- at property (readonly) void *JSObject WEBKIT_OBJC_METHOD_ANNOTATION(AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER);
- at property (getter=isIgnoringInteractionEvents, readonly) BOOL ignoringInteractionEvents;
-
- at property (getter=getStringValue, strong) NSString *stringValue;
- at property (getter=getCounterValue, readonly) BOOL counterValue;
- at property (getter=getns_dixtionary, readonly, copy) NSDictionary *ns_dixtionary;
-
-- (BOOL)is3bar; // watch out
-- (NSString *)get3foo; // watch out
-
- at property (getter=getM, readonly) BOOL m;
- at property (getter=getMA, readonly) BOOL MA;
- at property (getter=getALL, readonly) BOOL ALL;
- at property (getter=getMANY, readonly) BOOL MANY;
- at property (getter=getSome, readonly) BOOL some;
- at end
-
-
- at interface NSInvocation(CAT)
- at property (assign) id target;
-
- at property (assign) id dataSource;
-
- at property (assign) id xxxdelegateYYY;
-
-
- at property (strong) id MYtarget;
-
- at property (strong) id targetX;
-
- at property int value;
-
- at property (getter=isContinuous) BOOL continuous;
-
-- (id) isAnObject;
-- (void)setAnObject : (id) object;
-
- at property (getter=isinValid, readonly) BOOL inValid;
-- (void) setInValid : (BOOL) arg;
-
-- (void) Nothing;
- at property (readonly) int Length;
- at property (readonly, strong) id object;
-+ (double) D;
-
-- (BOOL)is3bar; // watch out
-- (NSString *)get3foo; // watch out
-
- at property (getter=getM, readonly) BOOL m;
- at property (getter=getMA, readonly) BOOL MA;
- at property (getter=getALL, readonly) BOOL ALL;
- at property (getter=getMANY, readonly) BOOL MANY;
- at property (getter=getSome, readonly) BOOL some;
- at end
-
-DEPRECATED
- at interface I_DEP
-- (BOOL) isinValid;
-- (void) setInValid : (BOOL) arg;
- at end
-
- at interface AnotherOne
-- (BOOL) isinValid DEPRECATED;
-- (void) setInValid : (BOOL) arg;
-- (id)MYtarget;
-- (void)setMYtarget: (id)target DEPRECATED;
-- (BOOL) getM DEPRECATED;
-
-- (id)xxxdelegateYYY DEPRECATED;
-- (void)setXxxdelegateYYY:(id)delegate DEPRECATED;
- at end
-
-#define NS_AVAILABLE __attribute__((availability(macosx,introduced=10.0)))
-#define NORETURN __attribute__((noreturn))
-#define ALIGNED __attribute__((aligned(16)))
-
- at interface NSURL
-// Do not infer a property.
- at property (strong) NSURL *appStoreReceiptURL NS_AVAILABLE;
-- (void) setAppStoreReceiptURL : (NSURL *)object;
-
- at property (strong) NSURL *appStoreReceiptURLX NS_AVAILABLE;
-
-// Do not infer a property.
- at property (strong) NSURL *appStoreReceiptURLY ;
-- (void) setAppStoreReceiptURLY : (NSURL *)object NS_AVAILABLE;
-
- at property (readonly, strong) id OkToInfer NS_AVAILABLE;
-
-// Do not infer a property.
- at property (strong) NSURL *appStoreReceiptURLZ ;
-- (void) setAppStoreReceiptURLZ : (NSURL *)object NS_AVAILABLE;
-
-// Do not infer a property.
-- (id) t1 NORETURN NS_AVAILABLE;
-- (void) setT1 : (id) arg NS_AVAILABLE;
-
- at property (strong) id method1 ALIGNED NS_AVAILABLE;
-
-- (NSURL *)init; // No Change
-+ (id)alloc; // No Change
-
-- (BOOL)is1stClass; // Not a valid property
- at property (getter=isClass, readonly) BOOL class; // This is a valid property 'class' is not a keyword in ObjC
-- (BOOL)isDouble; // Not a valid property
-
- at end
-
- at class NSMutableDictionary;
-
- at interface NSArray
- at property (readonly, copy) id (^expressionBlock)(id, NSArray *, NSMutableDictionary *);
- at property (copy) id (^MyBlock)(id, NSArray *, NSMutableDictionary *);
- at property (readonly) id (*expressionFuncptr)(id, NSArray *, NSMutableDictionary *);
- at property id (*MyFuncptr)(id, NSArray *, NSMutableDictionary *);
- at end
diff --git a/clang/test/ARCMT/objcmt-boxing.m b/clang/test/ARCMT/objcmt-boxing.m
deleted file mode 100644
index 07ee68dda33bd7..00000000000000
--- a/clang/test/ARCMT/objcmt-boxing.m
+++ /dev/null
@@ -1,106 +0,0 @@
-// RUN: rm -rf %t
-// RUN: %clang_cc1 -fobjc-arc -objcmt-migrate-literals -objcmt-migrate-subscripting -mt-migrate-directory %t %s -x objective-c++ -verify
-// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c++ %s.result
-
-#define YES __objc_yes
-#define NO __objc_no
-
-typedef long NSInteger;
-typedef unsigned long NSUInteger;
-typedef signed char BOOL;
-#define nil ((void*) 0)
-
-#define INT_MIN (-__INT_MAX__ -1)
-
- at interface NSObject
-+ (id)alloc;
- at end
-
- at interface NSNumber : NSObject
- at end
-
- at interface NSNumber (NSNumberCreation)
-- (id)initWithChar:(char)value;
-- (id)initWithUnsignedChar:(unsigned char)value;
-- (id)initWithShort:(short)value;
-- (id)initWithUnsignedShort:(unsigned short)value;
-- (id)initWithInt:(int)value;
-- (id)initWithUnsignedInt:(unsigned int)value;
-- (id)initWithLong:(long)value;
-- (id)initWithUnsignedLong:(unsigned long)value;
-- (id)initWithLongLong:(long long)value;
-- (id)initWithUnsignedLongLong:(unsigned long long)value;
-- (id)initWithFloat:(float)value;
-- (id)initWithDouble:(double)value;
-- (id)initWithBool:(BOOL)value;
-- (id)initWithInteger:(NSInteger)value;
-- (id)initWithUnsignedInteger:(NSUInteger)value;
-
-+ (NSNumber *)numberWithChar:(char)value;
-+ (NSNumber *)numberWithUnsignedChar:(unsigned char)value;
-+ (NSNumber *)numberWithShort:(short)value;
-+ (NSNumber *)numberWithUnsignedShort:(unsigned short)value;
-+ (NSNumber *)numberWithInt:(int)value;
-+ (NSNumber *)numberWithUnsignedInt:(unsigned int)value;
-+ (NSNumber *)numberWithLong:(long)value;
-+ (NSNumber *)numberWithUnsignedLong:(unsigned long)value;
-+ (NSNumber *)numberWithLongLong:(long long)value;
-+ (NSNumber *)numberWithUnsignedLongLong:(unsigned long long)value;
-+ (NSNumber *)numberWithFloat:(float)value;
-+ (NSNumber *)numberWithDouble:(double)value;
-+ (NSNumber *)numberWithBool:(BOOL)value;
-+ (NSNumber *)numberWithInteger:(NSInteger)value;
-+ (NSNumber *)numberWithUnsignedInteger:(NSUInteger)value;
- at end
-
-enum {
- NSASCIIStringEncoding = 1,
- NSUTF8StringEncoding = 4,
- NSUnicodeStringEncoding = 10
-};
-typedef NSUInteger NSStringEncoding;
-
- at interface NSString : NSObject
- at end
-
- at interface NSString (NSStringExtensionMethods)
-+ (id)stringWithUTF8String:(const char *)nullTerminatedCString;
-+ (id)stringWithCString:(const char *)cString encoding:(NSStringEncoding)enc;
-+ (id)stringWithCString:(const char *)bytes;
-- (instancetype)initWithUTF8String:(const char *)nullTerminatedCString;
- at end
-
-enum MyEnm {
- ME_foo
-};
-
-void foo() {
- [NSNumber numberWithInt:INT_MIN];
- bool cppb;
- [NSNumber numberWithBool:cppb];
- MyEnm myenum;
- [NSNumber numberWithInteger:myenum];
- [NSNumber numberWithInteger:ME_foo];
- [NSNumber numberWithDouble:cppb]; // expected-warning {{converting to boxing syntax requires casting 'bool' to 'double'}}
-}
-
-void boxString() {
- NSString *s = [NSString stringWithUTF8String:"box"];
- const char *cstr1;
- char *cstr2;
- s = [NSString stringWithUTF8String:cstr1];
- s = [NSString stringWithUTF8String:cstr2];
- s = [NSString stringWithCString:cstr1 encoding:NSASCIIStringEncoding];
- s = [NSString stringWithCString:cstr1 encoding:NSUTF8StringEncoding];
- s = [NSString stringWithCString:cstr1 encoding: NSUnicodeStringEncoding];
- NSStringEncoding encode;
- s = [NSString stringWithCString:cstr1 encoding:encode];
- s = [NSString stringWithCString:cstr1];
-
- static const char strarr[] = "coolbox";
- s = [NSString stringWithUTF8String:strarr];
- const char *utf8Bytes = "blah";
- NSString *string1 = [NSString stringWithUTF8String:utf8Bytes];
- NSString *string2 = [[NSString alloc] initWithUTF8String:utf8Bytes];
-}
diff --git a/clang/test/ARCMT/objcmt-boxing.m.result b/clang/test/ARCMT/objcmt-boxing.m.result
deleted file mode 100644
index a60b35900bf384..00000000000000
--- a/clang/test/ARCMT/objcmt-boxing.m.result
+++ /dev/null
@@ -1,106 +0,0 @@
-// RUN: rm -rf %t
-// RUN: %clang_cc1 -fobjc-arc -objcmt-migrate-literals -objcmt-migrate-subscripting -mt-migrate-directory %t %s -x objective-c++ -verify
-// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c++ %s.result
-
-#define YES __objc_yes
-#define NO __objc_no
-
-typedef long NSInteger;
-typedef unsigned long NSUInteger;
-typedef signed char BOOL;
-#define nil ((void*) 0)
-
-#define INT_MIN (-__INT_MAX__ -1)
-
- at interface NSObject
-+ (id)alloc;
- at end
-
- at interface NSNumber : NSObject
- at end
-
- at interface NSNumber (NSNumberCreation)
-- (id)initWithChar:(char)value;
-- (id)initWithUnsignedChar:(unsigned char)value;
-- (id)initWithShort:(short)value;
-- (id)initWithUnsignedShort:(unsigned short)value;
-- (id)initWithInt:(int)value;
-- (id)initWithUnsignedInt:(unsigned int)value;
-- (id)initWithLong:(long)value;
-- (id)initWithUnsignedLong:(unsigned long)value;
-- (id)initWithLongLong:(long long)value;
-- (id)initWithUnsignedLongLong:(unsigned long long)value;
-- (id)initWithFloat:(float)value;
-- (id)initWithDouble:(double)value;
-- (id)initWithBool:(BOOL)value;
-- (id)initWithInteger:(NSInteger)value;
-- (id)initWithUnsignedInteger:(NSUInteger)value;
-
-+ (NSNumber *)numberWithChar:(char)value;
-+ (NSNumber *)numberWithUnsignedChar:(unsigned char)value;
-+ (NSNumber *)numberWithShort:(short)value;
-+ (NSNumber *)numberWithUnsignedShort:(unsigned short)value;
-+ (NSNumber *)numberWithInt:(int)value;
-+ (NSNumber *)numberWithUnsignedInt:(unsigned int)value;
-+ (NSNumber *)numberWithLong:(long)value;
-+ (NSNumber *)numberWithUnsignedLong:(unsigned long)value;
-+ (NSNumber *)numberWithLongLong:(long long)value;
-+ (NSNumber *)numberWithUnsignedLongLong:(unsigned long long)value;
-+ (NSNumber *)numberWithFloat:(float)value;
-+ (NSNumber *)numberWithDouble:(double)value;
-+ (NSNumber *)numberWithBool:(BOOL)value;
-+ (NSNumber *)numberWithInteger:(NSInteger)value;
-+ (NSNumber *)numberWithUnsignedInteger:(NSUInteger)value;
- at end
-
-enum {
- NSASCIIStringEncoding = 1,
- NSUTF8StringEncoding = 4,
- NSUnicodeStringEncoding = 10
-};
-typedef NSUInteger NSStringEncoding;
-
- at interface NSString : NSObject
- at end
-
- at interface NSString (NSStringExtensionMethods)
-+ (id)stringWithUTF8String:(const char *)nullTerminatedCString;
-+ (id)stringWithCString:(const char *)cString encoding:(NSStringEncoding)enc;
-+ (id)stringWithCString:(const char *)bytes;
-- (instancetype)initWithUTF8String:(const char *)nullTerminatedCString;
- at end
-
-enum MyEnm {
- ME_foo
-};
-
-void foo() {
- @INT_MIN;
- bool cppb;
- @(cppb);
- MyEnm myenum;
- @(myenum);
- @(ME_foo);
- [NSNumber numberWithDouble:cppb]; // expected-warning {{converting to boxing syntax requires casting 'bool' to 'double'}}
-}
-
-void boxString() {
- NSString *s = @"box";
- const char *cstr1;
- char *cstr2;
- s = @(cstr1);
- s = @(cstr2);
- s = @(cstr1);
- s = @(cstr1);
- s = [NSString stringWithCString:cstr1 encoding: NSUnicodeStringEncoding];
- NSStringEncoding encode;
- s = [NSString stringWithCString:cstr1 encoding:encode];
- s = @(cstr1);
-
- static const char strarr[] = "coolbox";
- s = @(strarr);
- const char *utf8Bytes = "blah";
- NSString *string1 = @(utf8Bytes);
- NSString *string2 = @(utf8Bytes);
-}
diff --git a/clang/test/ARCMT/objcmt-designated-initializer.m b/clang/test/ARCMT/objcmt-designated-initializer.m
deleted file mode 100644
index 279d4f35d8eb19..00000000000000
--- a/clang/test/ARCMT/objcmt-designated-initializer.m
+++ /dev/null
@@ -1,44 +0,0 @@
-// RUN: rm -rf %t
-// RUN: %clang_cc1 -objcmt-migrate-designated-init %s -triple x86_64-apple-darwin11 -fobjc-arc -migrate -o %t.remap
-// RUN: c-arcmt-test %t.remap | arcmt-test -verify-transformed-files %s.result
-// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -x objective-c -fobjc-arc %s.result
-
-#define NS_DESIGNATED_INITIALIZER __attribute__((objc_designated_initializer))
-
- at class NSString;
-
- at interface B1
--(id)init;
- at end
-
- at interface S1 : B1
--(id)initWithFoo:(NSString*)foo;
- at end
-
- at implementation S1
--(id)initWithFoo:(NSString*)foo
-{
- self = [super init];
- if (self) {
- }
- return self;
-}
- at end
-
- at interface B2
--(id)init NS_DESIGNATED_INITIALIZER;
- at end
-
- at interface S2 : B2
--(id)init;
- at end
-
- at implementation S2
--(id)init
-{
- self = [super init];
- if (self) {
- }
- return self;
-}
- at end
diff --git a/clang/test/ARCMT/objcmt-designated-initializer.m.result b/clang/test/ARCMT/objcmt-designated-initializer.m.result
deleted file mode 100644
index 4c59b0cc582616..00000000000000
--- a/clang/test/ARCMT/objcmt-designated-initializer.m.result
+++ /dev/null
@@ -1,44 +0,0 @@
-// RUN: rm -rf %t
-// RUN: %clang_cc1 -objcmt-migrate-designated-init %s -triple x86_64-apple-darwin11 -fobjc-arc -migrate -o %t.remap
-// RUN: c-arcmt-test %t.remap | arcmt-test -verify-transformed-files %s.result
-// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -x objective-c -fobjc-arc %s.result
-
-#define NS_DESIGNATED_INITIALIZER __attribute__((objc_designated_initializer))
-
- at class NSString;
-
- at interface B1
--(id)init;
- at end
-
- at interface S1 : B1
--(id)initWithFoo:(NSString*)foo NS_DESIGNATED_INITIALIZER;
- at end
-
- at implementation S1
--(id)initWithFoo:(NSString*)foo
-{
- self = [super init];
- if (self) {
- }
- return self;
-}
- at end
-
- at interface B2
--(id)init NS_DESIGNATED_INITIALIZER;
- at end
-
- at interface S2 : B2
--(id)init;
- at end
-
- at implementation S2
--(id)init
-{
- self = [super init];
- if (self) {
- }
- return self;
-}
- at end
diff --git a/clang/test/ARCMT/objcmt-instancetype-2.m b/clang/test/ARCMT/objcmt-instancetype-2.m
deleted file mode 100644
index fb59265c4be32b..00000000000000
--- a/clang/test/ARCMT/objcmt-instancetype-2.m
+++ /dev/null
@@ -1,103 +0,0 @@
-// RUN: rm -rf %t
-// RUN: %clang_cc1 -objcmt-migrate-instancetype -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11
-// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result
-// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -x objective-c -fobjc-runtime-has-weak -fobjc-arc %s.result
-
-typedef unsigned int NSUInteger;
-typedef int NSInteger;
-typedef char BOOL;
- at class NSData, NSError, NSProtocolChecker, NSObject;
- at class NSPortNameServer, NSTimeZone;
-
- at interface NSMutableString
- at end
-
- at interface NSString @end
-
- at class NSString, NSURL;
- at interface NSString (NSStringDeprecated)
-+ (id)stringWithContentsOfFile:(NSString *)path __attribute__((availability(macosx,introduced=10.0 ,message="" )));
-+ (id)stringWithContentsOfURL:(NSURL *)url __attribute__((availability(macosx,introduced=10.0 ,message="" )));
-+ (id)stringWithCString:(const char *)bytes length:(NSUInteger)length __attribute__((availability(macosx,introduced=10.0 ,message="" )));
-+ (id)stringWithCString:(const char *)bytes __attribute__((availability(macosx,introduced=10.0 ,message="" )));
- at end
-
-
-typedef enum NSURLBookmarkResolutionOptions {
- Bookmark
-} NSURLBookmarkResolutionOptions;
-
- at interface NSURL
-+ (id)URLWithString:(NSString *)URLString;
-+ (id)URLWithString:(NSString *)URLString relativeToURL:(NSURL *)baseURL;
-+ (id)URLByResolvingBookmarkData:(NSData *)bookmarkData options:(NSURLBookmarkResolutionOptions)options relativeToURL:(NSURL *)relativeURL bookmarkDataIsStale:(BOOL *)isStale error:(NSError **)error __attribute__((availability(macosx,introduced=10.6)));
- at end
-
- at class NSDictionary;
- at interface NSError
-+ (id)errorWithDomain:(NSString *)domain code:(NSInteger)code userInfo:(NSDictionary *)dict;
- at end
-
-
- at interface NSMutableString (NSMutableStringExtensionMethods)
-+ (id)stringWithCapacity:(NSUInteger)capacity;
- at end
-
- at interface NSMutableData
-+ (id)dataWithCapacity:(NSUInteger)aNumItems;
-+ (id)dataWithLength:(NSUInteger)length;
- at end
-
- at interface NSMutableDictionary @end
-
- at interface NSMutableDictionary (NSSharedKeySetDictionary)
-+ (id )dictionaryWithSharedKeySet:(id)keyset __attribute__((availability(macosx,introduced=10.8)));
- at end
-
- at interface NSProtocolChecker
-+ (id)protocolCheckerWithTarget:(NSObject *)anObject protocol:(Protocol *)aProtocol;
- at end
-
- at interface NSConnection
-+ (id)connectionWithRegisteredName:(NSString *)name host:(NSString *)hostName;
-+ (id)connectionWithRegisteredName:(NSString *)name host:(NSString *)hostName usingNameServer:(NSPortNameServer *)server;
- at end
-
- at interface NSDate
-+ (id)dateWithString:(NSString *)aString __attribute__((availability(macosx,introduced=10.4)));
- at end
-
- at interface NSCalendarDate : NSDate
-+ (id)calendarDate __attribute__((availability(macosx,introduced=10.4)));
-+ (id)dateWithString:(NSString *)description calendarFormat:(NSString *)format locale:(id)locale __attribute__((availability(macosx,introduced=10.4)));
-+ (id)dateWithString:(NSString *)description calendarFormat:(NSString *)format __attribute__((availability(macosx,introduced=10.4)));
-+ (id)dateWithYear:(NSInteger)year month:(NSUInteger)month day:(NSUInteger)day hour:(NSUInteger)hour minute:(NSUInteger)minute second:(NSUInteger)second timeZone:(NSTimeZone *)aTimeZone __attribute__((availability(macosx,introduced=10.4)));
- at end
-
- at interface NSUserDefaults
-+ (id) standardUserDefaults;
- at end
-
- at interface NSNotificationCenter
-+ (id) defaultCenter;
-+ sharedCenter;
- at end
-
- at interface UIApplication
-+ (id)sharedApplication;
-+ defaultApplication;
- at end
-
-//===----------------------------------------------------------------------===//
-// Method name that has a null IdentifierInfo* for its first selector slot.
-// This test just makes sure that we handle it.
-//===----------------------------------------------------------------------===//
- at interface TestNullIdentifier
- at end
-
- at implementation TestNullIdentifier
-+ (id):(int)x, ... {
- return 0;
-}
- at end
-
diff --git a/clang/test/ARCMT/objcmt-instancetype-2.m.result b/clang/test/ARCMT/objcmt-instancetype-2.m.result
deleted file mode 100644
index 7a32894f570602..00000000000000
--- a/clang/test/ARCMT/objcmt-instancetype-2.m.result
+++ /dev/null
@@ -1,103 +0,0 @@
-// RUN: rm -rf %t
-// RUN: %clang_cc1 -objcmt-migrate-instancetype -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11
-// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result
-// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -x objective-c -fobjc-runtime-has-weak -fobjc-arc %s.result
-
-typedef unsigned int NSUInteger;
-typedef int NSInteger;
-typedef char BOOL;
- at class NSData, NSError, NSProtocolChecker, NSObject;
- at class NSPortNameServer, NSTimeZone;
-
- at interface NSMutableString
- at end
-
- at interface NSString @end
-
- at class NSString, NSURL;
- at interface NSString (NSStringDeprecated)
-+ (id)stringWithContentsOfFile:(NSString *)path __attribute__((availability(macosx,introduced=10.0 ,message="" )));
-+ (id)stringWithContentsOfURL:(NSURL *)url __attribute__((availability(macosx,introduced=10.0 ,message="" )));
-+ (id)stringWithCString:(const char *)bytes length:(NSUInteger)length __attribute__((availability(macosx,introduced=10.0 ,message="" )));
-+ (id)stringWithCString:(const char *)bytes __attribute__((availability(macosx,introduced=10.0 ,message="" )));
- at end
-
-
-typedef enum NSURLBookmarkResolutionOptions {
- Bookmark
-} NSURLBookmarkResolutionOptions;
-
- at interface NSURL
-+ (instancetype)URLWithString:(NSString *)URLString;
-+ (instancetype)URLWithString:(NSString *)URLString relativeToURL:(NSURL *)baseURL;
-+ (instancetype)URLByResolvingBookmarkData:(NSData *)bookmarkData options:(NSURLBookmarkResolutionOptions)options relativeToURL:(NSURL *)relativeURL bookmarkDataIsStale:(BOOL *)isStale error:(NSError **)error __attribute__((availability(macosx,introduced=10.6)));
- at end
-
- at class NSDictionary;
- at interface NSError
-+ (instancetype)errorWithDomain:(NSString *)domain code:(NSInteger)code userInfo:(NSDictionary *)dict;
- at end
-
-
- at interface NSMutableString (NSMutableStringExtensionMethods)
-+ (instancetype)stringWithCapacity:(NSUInteger)capacity;
- at end
-
- at interface NSMutableData
-+ (instancetype)dataWithCapacity:(NSUInteger)aNumItems;
-+ (instancetype)dataWithLength:(NSUInteger)length;
- at end
-
- at interface NSMutableDictionary @end
-
- at interface NSMutableDictionary (NSSharedKeySetDictionary)
-+ (instancetype )dictionaryWithSharedKeySet:(id)keyset __attribute__((availability(macosx,introduced=10.8)));
- at end
-
- at interface NSProtocolChecker
-+ (instancetype)protocolCheckerWithTarget:(NSObject *)anObject protocol:(Protocol *)aProtocol;
- at end
-
- at interface NSConnection
-+ (instancetype)connectionWithRegisteredName:(NSString *)name host:(NSString *)hostName;
-+ (instancetype)connectionWithRegisteredName:(NSString *)name host:(NSString *)hostName usingNameServer:(NSPortNameServer *)server;
- at end
-
- at interface NSDate
-+ (instancetype)dateWithString:(NSString *)aString __attribute__((availability(macosx,introduced=10.4)));
- at end
-
- at interface NSCalendarDate : NSDate
-+ (instancetype)calendarDate __attribute__((availability(macosx,introduced=10.4)));
-+ (instancetype)dateWithString:(NSString *)description calendarFormat:(NSString *)format locale:(id)locale __attribute__((availability(macosx,introduced=10.4)));
-+ (instancetype)dateWithString:(NSString *)description calendarFormat:(NSString *)format __attribute__((availability(macosx,introduced=10.4)));
-+ (instancetype)dateWithYear:(NSInteger)year month:(NSUInteger)month day:(NSUInteger)day hour:(NSUInteger)hour minute:(NSUInteger)minute second:(NSUInteger)second timeZone:(NSTimeZone *)aTimeZone __attribute__((availability(macosx,introduced=10.4)));
- at end
-
- at interface NSUserDefaults
-+ (instancetype) standardUserDefaults;
- at end
-
- at interface NSNotificationCenter
-+ (NSNotificationCenter*) defaultCenter;
-+ (NSNotificationCenter*) sharedCenter;
- at end
-
- at interface UIApplication
-+ (UIApplication*)sharedApplication;
-+ (UIApplication*) defaultApplication;
- at end
-
-//===----------------------------------------------------------------------===//
-// Method name that has a null IdentifierInfo* for its first selector slot.
-// This test just makes sure that we handle it.
-//===----------------------------------------------------------------------===//
- at interface TestNullIdentifier
- at end
-
- at implementation TestNullIdentifier
-+ (id):(int)x, ... {
- return 0;
-}
- at end
-
diff --git a/clang/test/ARCMT/objcmt-instancetype-unnecessary-diff.m b/clang/test/ARCMT/objcmt-instancetype-unnecessary-diff.m
deleted file mode 100644
index e250bb0956c050..00000000000000
--- a/clang/test/ARCMT/objcmt-instancetype-unnecessary-diff.m
+++ /dev/null
@@ -1,10 +0,0 @@
-// RUN: %clang_cc1 -objcmt-migrate-instancetype %s -triple x86_64-apple-darwin11 -fobjc-arc -migrate -o %t.remap
-// RUN: FileCheck %s -input-file=%t.remap
-
-// Make sure we don't create an edit unnecessarily.
-// CHECK-NOT: instancetype
-
- at class NSString;
- at interface NSDictionary
-+(instancetype) dictionaryWithURLEncodedString:(NSString *)urlEncodedString;
- at end
diff --git a/clang/test/ARCMT/objcmt-instancetype.m b/clang/test/ARCMT/objcmt-instancetype.m
deleted file mode 100644
index 17dd5a46b1e785..00000000000000
--- a/clang/test/ARCMT/objcmt-instancetype.m
+++ /dev/null
@@ -1,111 +0,0 @@
-// RUN: rm -rf %t
-// RUN: %clang_cc1 -objcmt-migrate-instancetype -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11
-// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result
-// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -x objective-c -fobjc-runtime-has-weak -fobjc-arc %s.result
-
-typedef signed char BOOL;
-#define nil ((void*) 0)
-
- at interface NSObject
-+ (id)alloc;
- at end
-
- at interface NSString : NSObject
-+ (id)stringWithString:(NSString *)string;
-- (id)initWithString:(NSString *)aString;
- at end
-
- at implementation NSString : NSObject
-+ (id)stringWithString:(NSString *)string { return 0; };
-- (instancetype)initWithString:(NSString *)aString { return 0; };
- at end
-
- at interface NSArray : NSObject
-- (id)objectAtIndex:(unsigned long)index;
-- (id)objectAtIndexedSubscript:(int)index;
- at end
-
- at interface NSArray (NSArrayCreation)
-+ (id)array;
-+ (id)arrayWithObject:(id)anObject;
-+ (id)arrayWithObjects:(const id [])objects count:(unsigned long)cnt;
-+ (id)arrayWithObjects:(id)firstObj, ...;
-+ arrayWithArray:(NSArray *)array;
-
-- (id)initWithObjects:(const id [])objects count:(unsigned long)cnt;
-- (id)initWithObjects:(id)firstObj, ...;
-- (id)initWithArray:(NSArray *)array;
-
-- (id)objectAtIndex:(unsigned long)index;
- at end
-
- at implementation NSArray (NSArrayCreation)
-+ (id)array { return 0; }
-+ (id)arrayWithObject:(id)anObject {
- return anObject;
-}
-+ (id)arrayWithObjects:(const id [])objects count:(unsigned long)cnt { return 0; }
-+ (id)arrayWithObjects:(id)firstObj, ... {
- return 0; }
-+ arrayWithArray:(NSArray *)array {
- return 0;
-}
-
-- (id)initWithObjects:(const id [])objects count:(unsigned long)cnt { return 0; }
-- (id)initWithObjects:(id)firstObj, ... { return 0; }
-- (id)initWithArray:(NSArray *)array { return 0; }
-
-- (id)objectAtIndex:(unsigned long)index { return 0; }
- at end
-
- at interface NSMutableArray : NSArray
-- (void)replaceObjectAtIndex:(unsigned long)index withObject:(id)anObject;
-- (void)setObject:(id)object atIndexedSubscript:(int)index;
- at end
-
- at interface NSDictionary : NSObject
-- (id)objectForKeyedSubscript:(id)key;
- at end
-
- at interface NSDictionary (NSDictionaryCreation)
-+ (id)dictionary;
-+ (id)dictionaryWithObject:(id)object forKey:(id)key;
-+ (id)dictionaryWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt;
-+ dictionaryWithObjectsAndKeys:(id)firstObject, ...;
-+ (id)dictionaryWithDictionary:(NSDictionary *)dict;
-+ (id)dictionaryWithObjects:(NSArray *)objects forKeys:(NSArray *)keys;
-
-- (id)initWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt;
-- (id)initWithObjectsAndKeys:(id)firstObject, ...;
-- (id)initWithDictionary:(NSDictionary *)otherDictionary;
-- (id)initWithObjects:(NSArray *)objects forKeys:(NSArray *)keys;
-
-- (id)objectForKey:(id)aKey;
- at end
-
- at interface NSMutableDictionary : NSDictionary
-- (void)setObject:(id)anObject forKey:(id)aKey;
-- (void)setObject:(id)object forKeyedSubscript:(id)key;
- at end
-
- at interface NSNumber : NSObject
- at end
-
- at interface NSNumber (NSNumberCreation)
-+ (NSNumber *)numberWithInt:(int)value;
- at end
-
- at implementation NSNumber (NSNumberCreation)
-+ (NSNumber *)numberWithInt:(int)value { return 0; }
- at end
-
-#define M(x) (x)
-#define PAIR(x) @#x, [NSNumber numberWithInt:(x)]
-#define TWO(x) ((x), (x))
-
-void foo(void) {
- NSString *str = M([NSString stringWithString:@"foo"]); // expected-warning {{redundant}}
- str = [[NSString alloc] initWithString:@"foo"]; // expected-warning {{redundant}}
- NSArray *arr = [NSArray arrayWithArray:@[str]]; // expected-warning {{redundant}}
- NSDictionary *dict = [NSDictionary dictionaryWithDictionary:@{str: arr}]; // expected-warning {{redundant}}
-}
diff --git a/clang/test/ARCMT/objcmt-instancetype.m.result b/clang/test/ARCMT/objcmt-instancetype.m.result
deleted file mode 100644
index 5203368aad6442..00000000000000
--- a/clang/test/ARCMT/objcmt-instancetype.m.result
+++ /dev/null
@@ -1,111 +0,0 @@
-// RUN: rm -rf %t
-// RUN: %clang_cc1 -objcmt-migrate-instancetype -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11
-// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result
-// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -x objective-c -fobjc-runtime-has-weak -fobjc-arc %s.result
-
-typedef signed char BOOL;
-#define nil ((void*) 0)
-
- at interface NSObject
-+ (id)alloc;
- at end
-
- at interface NSString : NSObject
-+ (instancetype)stringWithString:(NSString *)string;
-- (instancetype)initWithString:(NSString *)aString;
- at end
-
- at implementation NSString : NSObject
-+ (instancetype)stringWithString:(NSString *)string { return 0; };
-- (instancetype)initWithString:(NSString *)aString { return 0; };
- at end
-
- at interface NSArray : NSObject
-- (id)objectAtIndex:(unsigned long)index;
-- (id)objectAtIndexedSubscript:(int)index;
- at end
-
- at interface NSArray (NSArrayCreation)
-+ (instancetype)array;
-+ (instancetype)arrayWithObject:(id)anObject;
-+ (instancetype)arrayWithObjects:(const id [])objects count:(unsigned long)cnt;
-+ (instancetype)arrayWithObjects:(id)firstObj, ...;
-+ (instancetype) arrayWithArray:(NSArray *)array;
-
-- (instancetype)initWithObjects:(const id [])objects count:(unsigned long)cnt;
-- (instancetype)initWithObjects:(id)firstObj, ...;
-- (instancetype)initWithArray:(NSArray *)array;
-
-- (id)objectAtIndex:(unsigned long)index;
- at end
-
- at implementation NSArray (NSArrayCreation)
-+ (instancetype)array { return 0; }
-+ (instancetype)arrayWithObject:(id)anObject {
- return anObject;
-}
-+ (instancetype)arrayWithObjects:(const id [])objects count:(unsigned long)cnt { return 0; }
-+ (instancetype)arrayWithObjects:(id)firstObj, ... {
- return 0; }
-+ (instancetype) arrayWithArray:(NSArray *)array {
- return 0;
-}
-
-- (instancetype)initWithObjects:(const id [])objects count:(unsigned long)cnt { return 0; }
-- (instancetype)initWithObjects:(id)firstObj, ... { return 0; }
-- (instancetype)initWithArray:(NSArray *)array { return 0; }
-
-- (id)objectAtIndex:(unsigned long)index { return 0; }
- at end
-
- at interface NSMutableArray : NSArray
-- (void)replaceObjectAtIndex:(unsigned long)index withObject:(id)anObject;
-- (void)setObject:(id)object atIndexedSubscript:(int)index;
- at end
-
- at interface NSDictionary : NSObject
-- (id)objectForKeyedSubscript:(id)key;
- at end
-
- at interface NSDictionary (NSDictionaryCreation)
-+ (instancetype)dictionary;
-+ (instancetype)dictionaryWithObject:(id)object forKey:(id)key;
-+ (instancetype)dictionaryWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt;
-+ (instancetype) dictionaryWithObjectsAndKeys:(id)firstObject, ...;
-+ (instancetype)dictionaryWithDictionary:(NSDictionary *)dict;
-+ (instancetype)dictionaryWithObjects:(NSArray *)objects forKeys:(NSArray *)keys;
-
-- (instancetype)initWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt;
-- (instancetype)initWithObjectsAndKeys:(id)firstObject, ...;
-- (instancetype)initWithDictionary:(NSDictionary *)otherDictionary;
-- (instancetype)initWithObjects:(NSArray *)objects forKeys:(NSArray *)keys;
-
-- (id)objectForKey:(id)aKey;
- at end
-
- at interface NSMutableDictionary : NSDictionary
-- (void)setObject:(id)anObject forKey:(id)aKey;
-- (void)setObject:(id)object forKeyedSubscript:(id)key;
- at end
-
- at interface NSNumber : NSObject
- at end
-
- at interface NSNumber (NSNumberCreation)
-+ (NSNumber *)numberWithInt:(int)value;
- at end
-
- at implementation NSNumber (NSNumberCreation)
-+ (NSNumber *)numberWithInt:(int)value { return 0; }
- at end
-
-#define M(x) (x)
-#define PAIR(x) @#x, [NSNumber numberWithInt:(x)]
-#define TWO(x) ((x), (x))
-
-void foo(void) {
- NSString *str = M([NSString stringWithString:@"foo"]); // expected-warning {{redundant}}
- str = [[NSString alloc] initWithString:@"foo"]; // expected-warning {{redundant}}
- NSArray *arr = [NSArray arrayWithArray:@[str]]; // expected-warning {{redundant}}
- NSDictionary *dict = [NSDictionary dictionaryWithDictionary:@{str: arr}]; // expected-warning {{redundant}}
-}
diff --git a/clang/test/ARCMT/objcmt-invalid-code.mm b/clang/test/ARCMT/objcmt-invalid-code.mm
deleted file mode 100644
index f780d3de57ed80..00000000000000
--- a/clang/test/ARCMT/objcmt-invalid-code.mm
+++ /dev/null
@@ -1,19 +0,0 @@
-// REQUIRES: x86-registered-target
-// RUN: rm -rf %t
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only %s -verify
-// RUN: not %clang_cc1 -triple x86_64-apple-darwin10 -objcmt-migrate-literals -objcmt-migrate-subscripting -mt-migrate-directory %t %s -x objective-c
-// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result
-
-// Make sure there is no crash.
-
- at interface NSObject @end
- at interface NSNumber : NSObject
- at end
-
- at interface NSNumber (NSNumberCreation)
-+ (NSNumber *)numberWithInt:(int)value;
- at end
-
-void foo(int x = undeclared) { // expected-error {{undeclared}}
- NSNumber *n = [NSNumber numberWithInt:1];
-}
diff --git a/clang/test/ARCMT/objcmt-invalid-code.mm.result b/clang/test/ARCMT/objcmt-invalid-code.mm.result
deleted file mode 100644
index 52b2db00f61096..00000000000000
--- a/clang/test/ARCMT/objcmt-invalid-code.mm.result
+++ /dev/null
@@ -1,19 +0,0 @@
-// REQUIRES: x86-registered-target
-// RUN: rm -rf %t
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only %s -verify
-// RUN: not %clang_cc1 -triple x86_64-apple-darwin10 -objcmt-migrate-literals -objcmt-migrate-subscripting -mt-migrate-directory %t %s -x objective-c
-// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result
-
-// Make sure there is no crash.
-
- at interface NSObject @end
- at interface NSNumber : NSObject
- at end
-
- at interface NSNumber (NSNumberCreation)
-+ (NSNumber *)numberWithInt:(int)value;
- at end
-
-void foo(int x = undeclared) { // expected-error {{undeclared}}
- NSNumber *n = @1;
-}
diff --git a/clang/test/ARCMT/objcmt-migrate-all.m b/clang/test/ARCMT/objcmt-migrate-all.m
deleted file mode 100644
index 0aa66756b761c7..00000000000000
--- a/clang/test/ARCMT/objcmt-migrate-all.m
+++ /dev/null
@@ -1,133 +0,0 @@
-// RUN: rm -rf %t
-// RUN: %clang_cc1 -objcmt-migrate-all -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11
-// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c -fobjc-runtime-has-weak -fobjc-arc %s.result
-
-#ifndef NS_RETURNS_INNER_POINTER // defined in iOS 6 for sure
-#define NS_RETURNS_INNER_POINTER __attribute__((objc_returns_inner_pointer))
-#endif
-
-#define CF_IMPLICIT_BRIDGING_ENABLED _Pragma("clang arc_cf_code_audited begin")
-
-#define CF_IMPLICIT_BRIDGING_DISABLED _Pragma("clang arc_cf_code_audited end")
-
-#if __has_feature(attribute_ns_returns_retained)
-#define NS_RETURNS_RETAINED __attribute__((ns_returns_retained))
-#endif
-#if __has_feature(attribute_cf_returns_retained)
-#define CF_RETURNS_RETAINED __attribute__((cf_returns_retained))
-#endif
-#if __has_feature(attribute_ns_returns_not_retained)
-#define NS_RETURNS_NOT_RETAINED __attribute__((ns_returns_not_retained))
-#endif
-#if __has_feature(attribute_cf_returns_not_retained)
-#define CF_RETURNS_NOT_RETAINED __attribute__((cf_returns_not_retained))
-#endif
-#if __has_feature(attribute_ns_consumes_self)
-#define NS_CONSUMES_SELF __attribute__((ns_consumes_self))
-#endif
-#if __has_feature(attribute_ns_consumed)
-#define NS_CONSUMED __attribute__((ns_consumed))
-#endif
-#if __has_feature(attribute_cf_consumed)
-#define CF_CONSUMED __attribute__((cf_consumed))
-#endif
-#if __has_attribute(ns_returns_autoreleased)
-#define NS_RETURNS_AUTORELEASED __attribute__((ns_returns_autoreleased))
-#endif
-
-#define NS_AVAILABLE __attribute__((availability(macosx,introduced=10.0)))
-
-CF_IMPLICIT_BRIDGING_ENABLED
-
-typedef unsigned long CFTypeID;
-typedef unsigned long CFOptionFlags;
-typedef unsigned long CFHashCode;
-
-typedef signed long CFIndex; /*AnyObj*/
-typedef const struct __CFArray * CFArrayRef;
-typedef struct {
- CFIndex location;
- CFIndex length;
-} CFRange;
-
-typedef void (*CFArrayApplierFunction)(const void *value, void *context);
-
-typedef enum CFComparisonResult : CFIndex CFComparisonResult; enum CFComparisonResult : CFIndex {
- kCFCompareLessThan = -1L,
- kCFCompareEqualTo = 0,
- kCFCompareGreaterThan = 1
-};
-
-
-typedef CFComparisonResult (*CFComparatorFunction)(const void *val1, const void *val2, void *context);
-
-typedef struct __CFArray * CFMutableArrayRef;
-
-typedef const struct __CFAttributedString *CFAttributedStringRef;
-typedef struct __CFAttributedString *CFMutableAttributedStringRef;
-
-typedef const struct __CFAllocator * CFAllocatorRef;
-
-typedef const struct __CFString * CFStringRef;
-typedef struct __CFString * CFMutableStringRef;
-
-typedef const struct __CFDictionary * CFDictionaryRef;
-typedef struct __CFDictionary * CFMutableDictionaryRef;
-
-typedef struct CGImage *CGImageRef;
-
-typedef struct OpaqueJSValue* JSObjectRef;
-
-typedef JSObjectRef TTJSObjectRef;
-typedef unsigned int NSUInteger;
-
-CF_IMPLICIT_BRIDGING_DISABLED
-
- at interface I
-- (void*) ReturnsInnerPointer;
-- (int*) AlreadyReturnsInnerPointer NS_RETURNS_INNER_POINTER;
- at end
-
- at interface UIImage
-- (CGImageRef)CGImage;
- at end
-
- at interface NSData
-- (void *)bytes;
-- (void **) ptr_bytes __attribute__((availability(macosx,unavailable)));
- at end
-
- at interface NSMutableData
-- (void *)mutableBytes __attribute__((deprecated)) __attribute__((unavailable));
- at end
-
- at interface JS
-- (JSObjectRef)JSObject;
-- (TTJSObjectRef)JSObject1;
-- (JSObjectRef*)JSObject2;
- at end
-
-typedef void *SecTrustRef;
-
- at interface NSURLProtectionSpace
- at property (readonly) SecTrustRef serverTrust NS_AVAILABLE;
-- (void *) FOO NS_AVAILABLE;
- at property (readonly) void * mitTrust NS_AVAILABLE;
-
- at property (readonly) void * mittiTrust;
-
- at property (readonly) SecTrustRef XserverTrust;
-
-- (SecTrustRef) FOO1 NS_AVAILABLE;
-
-+ (const NSURLProtectionSpace *)ProtectionSpace;
-
-// pointer personality functions
- at property NSUInteger (*hashFunction)(const void *item, NSUInteger (*size)(const void *item));
- at end
-
- at interface MustNotMigrateToInnerPointer
-- (void*) nono;
-- (void) setNono : (void*) val;
- at end
diff --git a/clang/test/ARCMT/objcmt-migrate-all.m.result b/clang/test/ARCMT/objcmt-migrate-all.m.result
deleted file mode 100644
index e0972875e11b81..00000000000000
--- a/clang/test/ARCMT/objcmt-migrate-all.m.result
+++ /dev/null
@@ -1,132 +0,0 @@
-// RUN: rm -rf %t
-// RUN: %clang_cc1 -objcmt-migrate-all -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11
-// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c -fobjc-runtime-has-weak -fobjc-arc %s.result
-
-#ifndef NS_RETURNS_INNER_POINTER // defined in iOS 6 for sure
-#define NS_RETURNS_INNER_POINTER __attribute__((objc_returns_inner_pointer))
-#endif
-
-#define CF_IMPLICIT_BRIDGING_ENABLED _Pragma("clang arc_cf_code_audited begin")
-
-#define CF_IMPLICIT_BRIDGING_DISABLED _Pragma("clang arc_cf_code_audited end")
-
-#if __has_feature(attribute_ns_returns_retained)
-#define NS_RETURNS_RETAINED __attribute__((ns_returns_retained))
-#endif
-#if __has_feature(attribute_cf_returns_retained)
-#define CF_RETURNS_RETAINED __attribute__((cf_returns_retained))
-#endif
-#if __has_feature(attribute_ns_returns_not_retained)
-#define NS_RETURNS_NOT_RETAINED __attribute__((ns_returns_not_retained))
-#endif
-#if __has_feature(attribute_cf_returns_not_retained)
-#define CF_RETURNS_NOT_RETAINED __attribute__((cf_returns_not_retained))
-#endif
-#if __has_feature(attribute_ns_consumes_self)
-#define NS_CONSUMES_SELF __attribute__((ns_consumes_self))
-#endif
-#if __has_feature(attribute_ns_consumed)
-#define NS_CONSUMED __attribute__((ns_consumed))
-#endif
-#if __has_feature(attribute_cf_consumed)
-#define CF_CONSUMED __attribute__((cf_consumed))
-#endif
-#if __has_attribute(ns_returns_autoreleased)
-#define NS_RETURNS_AUTORELEASED __attribute__((ns_returns_autoreleased))
-#endif
-
-#define NS_AVAILABLE __attribute__((availability(macosx,introduced=10.0)))
-
-CF_IMPLICIT_BRIDGING_ENABLED
-
-typedef unsigned long CFTypeID;
-typedef unsigned long CFOptionFlags;
-typedef unsigned long CFHashCode;
-
-typedef signed long CFIndex; /*AnyObj*/
-typedef const struct __CFArray * CFArrayRef;
-typedef struct {
- CFIndex location;
- CFIndex length;
-} CFRange;
-
-typedef void (*CFArrayApplierFunction)(const void *value, void *context);
-
-typedef enum CFComparisonResult : CFIndex CFComparisonResult; enum CFComparisonResult : CFIndex {
- kCFCompareLessThan = -1L,
- kCFCompareEqualTo = 0,
- kCFCompareGreaterThan = 1
-};
-
-
-typedef CFComparisonResult (*CFComparatorFunction)(const void *val1, const void *val2, void *context);
-
-typedef struct __CFArray * CFMutableArrayRef;
-
-typedef const struct __CFAttributedString *CFAttributedStringRef;
-typedef struct __CFAttributedString *CFMutableAttributedStringRef;
-
-typedef const struct __CFAllocator * CFAllocatorRef;
-
-typedef const struct __CFString * CFStringRef;
-typedef struct __CFString * CFMutableStringRef;
-
-typedef const struct __CFDictionary * CFDictionaryRef;
-typedef struct __CFDictionary * CFMutableDictionaryRef;
-
-typedef struct CGImage *CGImageRef;
-
-typedef struct OpaqueJSValue* JSObjectRef;
-
-typedef JSObjectRef TTJSObjectRef;
-typedef unsigned int NSUInteger;
-
-CF_IMPLICIT_BRIDGING_DISABLED
-
- at interface I
- at property (nonatomic, readonly) void *ReturnsInnerPointer;
- at property (nonatomic, readonly) int *AlreadyReturnsInnerPointer NS_RETURNS_INNER_POINTER;
- at end
-
- at interface UIImage
- at property (nonatomic, readonly) CGImageRef CGImage CF_RETURNS_NOT_RETAINED;
- at end
-
- at interface NSData
- at property (nonatomic, readonly) void *bytes;
- at property (nonatomic, readonly) void **ptr_bytes __attribute__((availability(macosx,unavailable)));
- at end
-
- at interface NSMutableData
- at property (nonatomic, readonly) void *mutableBytes __attribute__((deprecated)) __attribute__((unavailable));
- at end
-
- at interface JS
- at property (nonatomic, readonly) JSObjectRef JSObject;
- at property (nonatomic, readonly) TTJSObjectRef JSObject1;
- at property (nonatomic, readonly) JSObjectRef *JSObject2;
- at end
-
-typedef void *SecTrustRef;
-
- at interface NSURLProtectionSpace
- at property (readonly) SecTrustRef serverTrust NS_AVAILABLE;
- at property (nonatomic, readonly) void *FOO NS_AVAILABLE;
- at property (readonly) void * mitTrust NS_AVAILABLE;
-
- at property (readonly) void * mittiTrust;
-
- at property (readonly) SecTrustRef XserverTrust;
-
- at property (nonatomic, readonly) SecTrustRef FOO1 NS_AVAILABLE;
-
-+ (const NSURLProtectionSpace *)ProtectionSpace;
-
-// pointer personality functions
- at property NSUInteger (*hashFunction)(const void *item, NSUInteger (*size)(const void *item));
- at end
-
- at interface MustNotMigrateToInnerPointer
- at property (nonatomic) void *nono;
- at end
diff --git a/clang/test/ARCMT/objcmt-ns-enum-crash.m b/clang/test/ARCMT/objcmt-ns-enum-crash.m
deleted file mode 100644
index 7c9c708efaefba..00000000000000
--- a/clang/test/ARCMT/objcmt-ns-enum-crash.m
+++ /dev/null
@@ -1,14 +0,0 @@
-// RUN: rm -rf %t
-// RUN: %clang_cc1 -objcmt-migrate-ns-macros -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11
-// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result
-
-#define NS_ENUM(_type, _name) enum _name : _type _name; enum _name : _type
-#define NS_OPTIONS(_type, _name) enum _name : _type _name; enum _name : _type
-typedef long NSInteger;
-
-typedef enum : NSInteger {five} ApplicableEnum;
-
-typedef unsigned long mytd;
-
-#define MY_ENUM(name, type, ...) typedef enum : type { __VA_ARGS__ } name##_t
-MY_ENUM(MyEnum, unsigned int, One);
diff --git a/clang/test/ARCMT/objcmt-ns-enum-crash.m.result b/clang/test/ARCMT/objcmt-ns-enum-crash.m.result
deleted file mode 100644
index 0a76e66ea2111b..00000000000000
--- a/clang/test/ARCMT/objcmt-ns-enum-crash.m.result
+++ /dev/null
@@ -1,14 +0,0 @@
-// RUN: rm -rf %t
-// RUN: %clang_cc1 -objcmt-migrate-ns-macros -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11
-// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result
-
-#define NS_ENUM(_type, _name) enum _name : _type _name; enum _name : _type
-#define NS_OPTIONS(_type, _name) enum _name : _type _name; enum _name : _type
-typedef long NSInteger;
-
-typedef NS_ENUM(NSInteger, ApplicableEnum) {five};
-
-typedef unsigned long mytd;
-
-#define MY_ENUM(name, type, ...) typedef enum : type { __VA_ARGS__ } name##_t
-MY_ENUM(MyEnum, unsigned int, One);
diff --git a/clang/test/ARCMT/objcmt-ns-macros.m b/clang/test/ARCMT/objcmt-ns-macros.m
deleted file mode 100644
index 902e765bead3a3..00000000000000
--- a/clang/test/ARCMT/objcmt-ns-macros.m
+++ /dev/null
@@ -1,379 +0,0 @@
-// RUN: rm -rf %t
-// RUN: %clang_cc1 -objcmt-migrate-ns-macros -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11
-// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c -fobjc-runtime-has-weak -fobjc-arc %s.result
-
-typedef signed char int8_t;
-typedef short int16_t;
-typedef int int32_t;
-typedef long NSInteger;
-typedef long long int64_t;
-
-typedef unsigned char uint8_t;
-typedef unsigned short uint16_t;
-typedef unsigned int uint32_t;
-typedef unsigned long NSUInteger;
-typedef unsigned long long uint64_t;
-
-#define NS_ENUM(_type, _name) enum _name : _type _name; enum _name : _type
-#define NS_OPTIONS(_type, _name) enum _name : _type _name; enum _name : _type
-#define DEPRECATED __attribute__((deprecated))
-
-enum {
- blah,
- blarg
-};
-typedef NSInteger wibble;
-
-enum {
- UIViewAutoresizingNone = 0,
- UIViewAutoresizingFlexibleLeftMargin,
- UIViewAutoresizingFlexibleWidth,
- UIViewAutoresizingFlexibleRightMargin,
- UIViewAutoresizingFlexibleTopMargin,
- UIViewAutoresizingFlexibleHeight,
- UIViewAutoresizingFlexibleBottomMargin
-};
-typedef NSUInteger UITableViewCellStyle;
-
-typedef enum {
- UIViewAnimationTransitionNone,
- UIViewAnimationTransitionFlipFromLeft,
- UIViewAnimationTransitionFlipFromRight,
- UIViewAnimationTransitionCurlUp,
- UIViewAnimationTransitionCurlDown,
-} UIViewAnimationTransition;
-
-typedef enum {
- UIViewOne = 0,
- UIViewTwo = 1 << 0,
- UIViewThree = 1 << 1,
- UIViewFour = 1 << 2,
- UIViewFive = 1 << 3,
- UIViewSix = 1 << 4,
- UIViewSeven = 1 << 5
-} UITableView;
-
-enum {
- UIOne = 0,
- UITwo = 0x1,
- UIthree = 0x8,
- UIFour = 0x100
-};
-typedef NSInteger UI;
-
-typedef enum {
- UIP2One = 0,
- UIP2Two = 0x1,
- UIP2three = 0x8,
- UIP2Four = 0x100
-} UIPOWER2;
-
-enum {
- UNOne,
- UNTwo
-};
-
-// Should use NS_ENUM even though it is all power of 2.
-enum {
- UIKOne = 1,
- UIKTwo = 2,
-};
-typedef NSInteger UIK;
-
-typedef enum {
- NSTickMarkBelow = 0,
- NSTickMarkAbove = 1,
- NSTickMarkLeft = NSTickMarkAbove,
- NSTickMarkRight = NSTickMarkBelow
-} NSTickMarkPosition;
-
-enum {
- UIViewNone = 0x0,
- UIViewMargin = 0x1,
- UIViewWidth = 0x2,
- UIViewRightMargin = 0x3,
- UIViewBottomMargin = 0xbadbeef
-};
-typedef NSInteger UITableStyle;
-
-enum {
- UIView0 = 0,
- UIView1 = 0XBADBEEF
-};
-typedef NSInteger UIStyle;
-
-enum {
- NSTIFFFileType,
- NSBMPFileType,
- NSGIFFileType,
- NSJPEGFileType,
- NSPNGFileType,
- NSJPEG2000FileType
-};
-typedef NSUInteger NSBitmapImageFileType;
-
-enum {
- NSWarningAlertStyle = 0,
- NSInformationalAlertStyle = 1,
- NSCriticalAlertStyle = 2
-};
-typedef NSUInteger NSAlertStyle;
-
-enum {
- D_NSTIFFFileType,
- D_NSBMPFileType,
- D_NSGIFFileType,
- D_NSJPEGFileType,
- D_NSPNGFileType,
- D_NSJPEG2000FileType
-};
-typedef NSUInteger D_NSBitmapImageFileType DEPRECATED;
-
-typedef enum {
- D_NSTickMarkBelow = 0,
- D_NSTickMarkAbove = 1
-} D_NSTickMarkPosition DEPRECATED;
-
-
-#define NS_ENUM_AVAILABLE(X,Y)
-
-enum {
- NSFStrongMemory NS_ENUM_AVAILABLE(10_5, 6_0) = (0UL << 0),
- NSFOpaqueMemory NS_ENUM_AVAILABLE(10_5, 6_0) = (2UL << 0),
- NSFMallocMemory NS_ENUM_AVAILABLE(10_5, 6_0) = (3UL << 0),
- NSFMachVirtualMemory NS_ENUM_AVAILABLE(10_5, 6_0) = (4UL << 0),
- NSFWeakMemory NS_ENUM_AVAILABLE(10_8, 6_0) = (5UL << 0),
-
- NSFObjectPersonality NS_ENUM_AVAILABLE(10_5, 6_0) = (0UL << 8),
- NSFOpaquePersonality NS_ENUM_AVAILABLE(10_5, 6_0) = (1UL << 8),
- NSFObjectPointerPersonality NS_ENUM_AVAILABLE(10_5, 6_0) = (2UL << 8),
- NSFCStringPersonality NS_ENUM_AVAILABLE(10_5, 6_0) = (3UL << 8),
- NSFStructPersonality NS_ENUM_AVAILABLE(10_5, 6_0) = (4UL << 8),
- NSFIntegerPersonality NS_ENUM_AVAILABLE(10_5, 6_0) = (5UL << 8),
- NSFCopyIn NS_ENUM_AVAILABLE(10_5, 6_0) = (1UL << 16),
-};
-
-typedef NSUInteger NSFOptions;
-
-typedef enum {
- UIP0One = 0,
- UIP0Two = 1,
- UIP0Three = 2,
- UIP0Four = 10,
- UIP0Last = 0x100
-} UIP;
-
-typedef enum {
- UIPZero = 0x0,
- UIPOne = 0x1,
- UIPTwo = 0x2,
- UIP10 = 0x10,
- UIPHundred = 0x100
-} UIP_3;
-
-typedef enum {
- UIP4Zero = 0x0,
- UIP4One = 0x1,
- UIP4Two = 0x2,
- UIP410 = 0x10,
- UIP4Hundred = 100
-} UIP4_3;
-
-typedef enum {
- UIP5Zero = 0x0,
- UIP5Two = 0x2,
- UIP510 = 0x3,
- UIP5Hundred = 0x4
-} UIP5_3;
-
-typedef enum {
- UIP6Zero = 0x0,
- UIP6One = 0x1,
- UIP6Two = 0x2,
- UIP610 = 10,
- UIP6Hundred = 0x100
-} UIP6_3;
-
-typedef enum {
- UIP7Zero = 0x0,
- UIP7One = 1,
- UIP7Two = 0x2,
- UIP710 = 10,
- UIP7Hundred = 100
-} UIP7_3;
-
-
-typedef enum {
- Random = 0,
- Random1 = 2,
- Random2 = 4,
- Random3 = 0x12345,
- Random4 = 0x3444444,
- Random5 = 0xbadbeef,
- Random6
-} UIP8_3;
-
-#define NS_AVAILABLE_MAC(X) __attribute__((availability(macosx,introduced=X)))
-#define NS_ENUM_AVAILABLE_MAC(X) __attribute__((availability(macosx,introduced=X)))
-
-enum {
- NSModalResponseStop = (-1000), // Also used as the default response for sheets
- NSModalResponseAbort = (-1001),
- NSModalResponseContinue = (-1002),
-} NS_ENUM_AVAILABLE_MAC(10.9);
-typedef NSInteger NSModalResponse NS_AVAILABLE_MAC(10.9);
-
-typedef NSUInteger FarFarAwayOptions;
-
-typedef NSUInteger FarAwayOptions;
-enum {
- NSWorkspaceLaunchAndPrint = 0x00000002,
- NSWorkspaceLaunchWithErrorPresentation = 0x00000040,
- NSWorkspaceLaunchInhibitingBackgroundOnly = 0x00000080,
- NSWorkspaceLaunchWithoutAddingToRecents = 0x00000100,
- NSWorkspaceLaunchWithoutActivation = 0x00000200,
- NSWorkspaceLaunchAsync = 0x00010000,
- NSWorkspaceLaunchAllowingClassicStartup = 0x00020000,
- NSWorkspaceLaunchPreferringClassic = 0x00040000,
- NSWorkspaceLaunchNewInstance = 0x00080000,
- NSWorkspaceLaunchAndHide = 0x00100000,
- NSWorkspaceLaunchAndHideOthers = 0x00200000,
- NSWorkspaceLaunchDefault = NSWorkspaceLaunchAsync |
- NSWorkspaceLaunchAllowingClassicStartup
-};
-typedef NSUInteger NSWorkspaceLaunchOptions;
-
-enum {
- NSExcludeQuickDrawElementsIconCreationOption = 1 << 1,
- NSExclude10_4ElementsIconCreationOption = 1 << 2
-};
-typedef NSUInteger NSExcludeOptions;
-
-enum {
- NSExcludeQuickDrawElementsCreationOption = 1 << 1,
- NSExclude10_4ElementsCreationOption = 1 << 2
-};
-typedef NSUInteger NSExcludeCreationOption;
-
-enum {
- FarAway1 = 1 << 1,
- FarAway2 = 1 << 2
-};
-
-enum {
- NSExcludeQuickDrawElementsIconOption = 1 << 1,
- NSExclude10_4ElementsIconOption = 1 << 2
-};
-typedef NSUInteger NSExcludeIconOptions;
-
- at interface INTF {
- NSExcludeIconOptions I1;
- NSExcludeIconOptions I2;
-}
- at end
-
-enum {
- FarFarAway1 = 1 << 1,
- FarFarAway2 = 1 << 2
-};
-
-typedef NS_OPTIONS(NSUInteger, NSWindowOcclusionState) {
- NSWindowOcclusionStateVisible = 1UL << 1,
-};
-
-typedef NSUInteger NSWindowNumberListOptions;
-
-enum {
- NSDirectSelection = 0,
- NSSelectingNext,
- NSSelectingPrevious
-};
-typedef NSUInteger NSSelectionDirection;
-
-// standard window buttons
-enum {
- NSWindowCloseButton,
- NSWindowMiniaturizeButton,
- NSWindowZoomButton,
- NSWindowToolbarButton,
- NSWindowDocumentIconButton
-};
-
-typedef enum : NSUInteger {
- ThingOne,
- ThingTwo,
- ThingThree,
-} Thing;
-
-typedef enum {
- one = 1
-} NumericEnum;
-
-typedef enum {
- Two = 2
-}NumericEnum2;
-
-typedef enum {
- Three = 3
-}
-NumericEnum3;
-
-typedef enum {
- Four = 4
-}
-
- NumericEnum4;
-
-enum
-{
- UI8one = 1
-};
-typedef int8_t MyEnumeratedType;
-
-
-enum {
- UI16One = 0,
- UI16Two = 0x1,
- UI16three = 0x8,
- UI16Four = 0x100
-};
-typedef int16_t UI16;
-
-enum {
- UI32ViewAutoresizingNone = 0,
- UI32ViewAutoresizingFlexibleLeftMargin,
- UI32ViewAutoresizingFlexibleWidth,
- UI32ViewAutoresizingFlexibleRightMargin,
- UI32ViewAutoresizingFlexibleTopMargin,
- UI32ViewAutoresizingFlexibleHeight,
- UI32ViewAutoresizingFlexibleBottomMargin
-};
-typedef uint32_t UI32TableViewCellStyle;
-
-enum
-{
- UIU8one = 1
-};
-typedef uint8_t UI8Type;
-
-typedef enum : NSInteger {zero} MyEnum;
-
-typedef enum : NSUInteger {two} MyEnumNSUInteger;
-
-typedef enum : int {three, four} MyEnumint;
-
-typedef enum : unsigned long {five} MyEnumlonglong;
-
-typedef enum : unsigned long long {
- ll1,
- ll2= 0xff,
- ll3,
- ll4
-} MyEnumunsignedlonglong;
-
-typedef enum : int8_t {int8_one} MyOneEnum;
-
-typedef enum : int16_t {
- int16_t_one,
- int16_t_two } Myint16_tEnum;
diff --git a/clang/test/ARCMT/objcmt-ns-macros.m.result b/clang/test/ARCMT/objcmt-ns-macros.m.result
deleted file mode 100644
index d4c0870e8cdc3a..00000000000000
--- a/clang/test/ARCMT/objcmt-ns-macros.m.result
+++ /dev/null
@@ -1,355 +0,0 @@
-// RUN: rm -rf %t
-// RUN: %clang_cc1 -objcmt-migrate-ns-macros -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11
-// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c -fobjc-runtime-has-weak -fobjc-arc %s.result
-
-typedef signed char int8_t;
-typedef short int16_t;
-typedef int int32_t;
-typedef long NSInteger;
-typedef long long int64_t;
-
-typedef unsigned char uint8_t;
-typedef unsigned short uint16_t;
-typedef unsigned int uint32_t;
-typedef unsigned long NSUInteger;
-typedef unsigned long long uint64_t;
-
-#define NS_ENUM(_type, _name) enum _name : _type _name; enum _name : _type
-#define NS_OPTIONS(_type, _name) enum _name : _type _name; enum _name : _type
-#define DEPRECATED __attribute__((deprecated))
-
-typedef NS_ENUM(NSInteger, wibble) {
- blah,
- blarg
-};
-
-typedef NS_ENUM(NSUInteger, UITableViewCellStyle) {
- UIViewAutoresizingNone = 0,
- UIViewAutoresizingFlexibleLeftMargin,
- UIViewAutoresizingFlexibleWidth,
- UIViewAutoresizingFlexibleRightMargin,
- UIViewAutoresizingFlexibleTopMargin,
- UIViewAutoresizingFlexibleHeight,
- UIViewAutoresizingFlexibleBottomMargin
-};
-
-typedef NS_ENUM(unsigned int, UIViewAnimationTransition) {
- UIViewAnimationTransitionNone,
- UIViewAnimationTransitionFlipFromLeft,
- UIViewAnimationTransitionFlipFromRight,
- UIViewAnimationTransitionCurlUp,
- UIViewAnimationTransitionCurlDown,
-};
-
-typedef NS_OPTIONS(unsigned int, UITableView) {
- UIViewOne = 0,
- UIViewTwo = 1 << 0,
- UIViewThree = 1 << 1,
- UIViewFour = 1 << 2,
- UIViewFive = 1 << 3,
- UIViewSix = 1 << 4,
- UIViewSeven = 1 << 5
-};
-
-typedef NS_OPTIONS(NSUInteger, UI) {
- UIOne = 0,
- UITwo = 0x1,
- UIthree = 0x8,
- UIFour = 0x100
-};
-
-typedef NS_OPTIONS(unsigned int, UIPOWER2) {
- UIP2One = 0,
- UIP2Two = 0x1,
- UIP2three = 0x8,
- UIP2Four = 0x100
-};
-
-enum {
- UNOne,
- UNTwo
-};
-
-// Should use NS_ENUM even though it is all power of 2.
-typedef NS_ENUM(NSInteger, UIK) {
- UIKOne = 1,
- UIKTwo = 2,
-};
-
-typedef NS_ENUM(unsigned int, NSTickMarkPosition) {
- NSTickMarkBelow = 0,
- NSTickMarkAbove = 1,
- NSTickMarkLeft = NSTickMarkAbove,
- NSTickMarkRight = NSTickMarkBelow
-};
-
-typedef NS_OPTIONS(NSUInteger, UITableStyle) {
- UIViewNone = 0x0,
- UIViewMargin = 0x1,
- UIViewWidth = 0x2,
- UIViewRightMargin = 0x3,
- UIViewBottomMargin = 0xbadbeef
-};
-
-typedef NS_OPTIONS(NSUInteger, UIStyle) {
- UIView0 = 0,
- UIView1 = 0XBADBEEF
-};
-
-typedef NS_ENUM(NSUInteger, NSBitmapImageFileType) {
- NSTIFFFileType,
- NSBMPFileType,
- NSGIFFileType,
- NSJPEGFileType,
- NSPNGFileType,
- NSJPEG2000FileType
-};
-
-typedef NS_ENUM(NSUInteger, NSAlertStyle) {
- NSWarningAlertStyle = 0,
- NSInformationalAlertStyle = 1,
- NSCriticalAlertStyle = 2
-};
-
-enum {
- D_NSTIFFFileType,
- D_NSBMPFileType,
- D_NSGIFFileType,
- D_NSJPEGFileType,
- D_NSPNGFileType,
- D_NSJPEG2000FileType
-};
-typedef NSUInteger D_NSBitmapImageFileType DEPRECATED;
-
-typedef enum {
- D_NSTickMarkBelow = 0,
- D_NSTickMarkAbove = 1
-} D_NSTickMarkPosition DEPRECATED;
-
-
-#define NS_ENUM_AVAILABLE(X,Y)
-
-
-typedef NS_OPTIONS(NSUInteger, NSFOptions) {
- NSFStrongMemory NS_ENUM_AVAILABLE(10_5, 6_0) = (0UL << 0),
- NSFOpaqueMemory NS_ENUM_AVAILABLE(10_5, 6_0) = (2UL << 0),
- NSFMallocMemory NS_ENUM_AVAILABLE(10_5, 6_0) = (3UL << 0),
- NSFMachVirtualMemory NS_ENUM_AVAILABLE(10_5, 6_0) = (4UL << 0),
- NSFWeakMemory NS_ENUM_AVAILABLE(10_8, 6_0) = (5UL << 0),
-
- NSFObjectPersonality NS_ENUM_AVAILABLE(10_5, 6_0) = (0UL << 8),
- NSFOpaquePersonality NS_ENUM_AVAILABLE(10_5, 6_0) = (1UL << 8),
- NSFObjectPointerPersonality NS_ENUM_AVAILABLE(10_5, 6_0) = (2UL << 8),
- NSFCStringPersonality NS_ENUM_AVAILABLE(10_5, 6_0) = (3UL << 8),
- NSFStructPersonality NS_ENUM_AVAILABLE(10_5, 6_0) = (4UL << 8),
- NSFIntegerPersonality NS_ENUM_AVAILABLE(10_5, 6_0) = (5UL << 8),
- NSFCopyIn NS_ENUM_AVAILABLE(10_5, 6_0) = (1UL << 16),
-};
-
-typedef NS_ENUM(unsigned int, UIP) {
- UIP0One = 0,
- UIP0Two = 1,
- UIP0Three = 2,
- UIP0Four = 10,
- UIP0Last = 0x100
-};
-
-typedef NS_OPTIONS(unsigned int, UIP_3) {
- UIPZero = 0x0,
- UIPOne = 0x1,
- UIPTwo = 0x2,
- UIP10 = 0x10,
- UIPHundred = 0x100
-};
-
-typedef NS_ENUM(unsigned int, UIP4_3) {
- UIP4Zero = 0x0,
- UIP4One = 0x1,
- UIP4Two = 0x2,
- UIP410 = 0x10,
- UIP4Hundred = 100
-};
-
-typedef NS_OPTIONS(unsigned int, UIP5_3) {
- UIP5Zero = 0x0,
- UIP5Two = 0x2,
- UIP510 = 0x3,
- UIP5Hundred = 0x4
-};
-
-typedef NS_ENUM(unsigned int, UIP6_3) {
- UIP6Zero = 0x0,
- UIP6One = 0x1,
- UIP6Two = 0x2,
- UIP610 = 10,
- UIP6Hundred = 0x100
-};
-
-typedef NS_ENUM(unsigned int, UIP7_3) {
- UIP7Zero = 0x0,
- UIP7One = 1,
- UIP7Two = 0x2,
- UIP710 = 10,
- UIP7Hundred = 100
-};
-
-
-typedef NS_ENUM(unsigned int, UIP8_3) {
- Random = 0,
- Random1 = 2,
- Random2 = 4,
- Random3 = 0x12345,
- Random4 = 0x3444444,
- Random5 = 0xbadbeef,
- Random6
-};
-
-#define NS_AVAILABLE_MAC(X) __attribute__((availability(macosx,introduced=X)))
-#define NS_ENUM_AVAILABLE_MAC(X) __attribute__((availability(macosx,introduced=X)))
-
-typedef NS_ENUM(NSInteger, NSModalResponse) {
- NSModalResponseStop = (-1000), // Also used as the default response for sheets
- NSModalResponseAbort = (-1001),
- NSModalResponseContinue = (-1002),
-} NS_ENUM_AVAILABLE_MAC(10.9);
-
-typedef NSUInteger FarFarAwayOptions;
-
-typedef NS_OPTIONS(NSUInteger, FarAwayOptions) {
- FarAway1 = 1 << 1,
- FarAway2 = 1 << 2
-};
-typedef NS_OPTIONS(NSUInteger, NSWorkspaceLaunchOptions) {
- NSWorkspaceLaunchAndPrint = 0x00000002,
- NSWorkspaceLaunchWithErrorPresentation = 0x00000040,
- NSWorkspaceLaunchInhibitingBackgroundOnly = 0x00000080,
- NSWorkspaceLaunchWithoutAddingToRecents = 0x00000100,
- NSWorkspaceLaunchWithoutActivation = 0x00000200,
- NSWorkspaceLaunchAsync = 0x00010000,
- NSWorkspaceLaunchAllowingClassicStartup = 0x00020000,
- NSWorkspaceLaunchPreferringClassic = 0x00040000,
- NSWorkspaceLaunchNewInstance = 0x00080000,
- NSWorkspaceLaunchAndHide = 0x00100000,
- NSWorkspaceLaunchAndHideOthers = 0x00200000,
- NSWorkspaceLaunchDefault = NSWorkspaceLaunchAsync |
- NSWorkspaceLaunchAllowingClassicStartup
-};
-
-typedef NS_OPTIONS(NSUInteger, NSExcludeOptions) {
- NSExcludeQuickDrawElementsIconCreationOption = 1 << 1,
- NSExclude10_4ElementsIconCreationOption = 1 << 2
-};
-
-typedef NS_OPTIONS(NSUInteger, NSExcludeCreationOption) {
- NSExcludeQuickDrawElementsCreationOption = 1 << 1,
- NSExclude10_4ElementsCreationOption = 1 << 2
-};
-
-
-typedef NS_OPTIONS(NSUInteger, NSExcludeIconOptions) {
- NSExcludeQuickDrawElementsIconOption = 1 << 1,
- NSExclude10_4ElementsIconOption = 1 << 2
-};
-
- at interface INTF {
- NSExcludeIconOptions I1;
- NSExcludeIconOptions I2;
-}
- at end
-
-enum {
- FarFarAway1 = 1 << 1,
- FarFarAway2 = 1 << 2
-};
-
-typedef NS_OPTIONS(NSUInteger, NSWindowOcclusionState) {
- NSWindowOcclusionStateVisible = 1UL << 1,
-};
-
-typedef NS_ENUM(NSUInteger, NSWindowNumberListOptions) {
- NSWindowCloseButton,
- NSWindowMiniaturizeButton,
- NSWindowZoomButton,
- NSWindowToolbarButton,
- NSWindowDocumentIconButton
-};
-
-typedef NS_ENUM(NSUInteger, NSSelectionDirection) {
- NSDirectSelection = 0,
- NSSelectingNext,
- NSSelectingPrevious
-};
-
-// standard window buttons
-
-typedef NS_ENUM(NSUInteger, Thing) {
- ThingOne,
- ThingTwo,
- ThingThree,
-};
-
-typedef NS_ENUM(unsigned int, NumericEnum) {
- one = 1
-};
-
-typedef NS_ENUM(unsigned int, NumericEnum2) {
- Two = 2
-};
-
-typedef NS_ENUM(unsigned int, NumericEnum3) {
- Three = 3
-};
-
-typedef NS_OPTIONS(unsigned int, NumericEnum4) {
- Four = 4
-};
-
-typedef NS_ENUM(int8_t, MyEnumeratedType)
-{
- UI8one = 1
-};
-
-
-typedef NS_OPTIONS(uint16_t, UI16) {
- UI16One = 0,
- UI16Two = 0x1,
- UI16three = 0x8,
- UI16Four = 0x100
-};
-
-typedef NS_ENUM(uint32_t, UI32TableViewCellStyle) {
- UI32ViewAutoresizingNone = 0,
- UI32ViewAutoresizingFlexibleLeftMargin,
- UI32ViewAutoresizingFlexibleWidth,
- UI32ViewAutoresizingFlexibleRightMargin,
- UI32ViewAutoresizingFlexibleTopMargin,
- UI32ViewAutoresizingFlexibleHeight,
- UI32ViewAutoresizingFlexibleBottomMargin
-};
-
-typedef NS_ENUM(uint8_t, UI8Type)
-{
- UIU8one = 1
-};
-
-typedef NS_ENUM(NSInteger, MyEnum) {zero};
-
-typedef NS_ENUM(NSUInteger, MyEnumNSUInteger) {two};
-
-typedef NS_ENUM(int, MyEnumint) {three, four};
-
-typedef NS_ENUM(unsigned long, MyEnumlonglong) {five};
-
-typedef NS_ENUM(unsigned long long, MyEnumunsignedlonglong) {
- ll1,
- ll2= 0xff,
- ll3,
- ll4
-};
-
-typedef NS_ENUM(int8_t, MyOneEnum) {int8_one};
-
-typedef NS_ENUM(int16_t, Myint16_tEnum) {
- int16_t_one,
- int16_t_two };
diff --git a/clang/test/ARCMT/objcmt-ns-nonatomic-iosonly.m b/clang/test/ARCMT/objcmt-ns-nonatomic-iosonly.m
deleted file mode 100644
index 55a116c8ca5da4..00000000000000
--- a/clang/test/ARCMT/objcmt-ns-nonatomic-iosonly.m
+++ /dev/null
@@ -1,233 +0,0 @@
-// RUN: rm -rf %t
-// RUN: %clang_cc1 -fblocks -objcmt-migrate-readwrite-property -objcmt-ns-nonatomic-iosonly -objcmt-migrate-readonly-property -objcmt-atomic-property -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11
-// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result
-// RUN: %clang_cc1 -fblocks -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c -fobjc-runtime-has-weak -fobjc-arc %s.result
-
-#define WEBKIT_OBJC_METHOD_ANNOTATION(ANNOTATION) ANNOTATION
-#define WEAK_IMPORT_ATTRIBUTE __attribute__((objc_arc_weak_reference_unavailable))
-#define AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER
-#define DEPRECATED __attribute__((deprecated))
-
-#if TARGET_OS_IPHONE
- #define NS_NONATOMIC_IOSONLY nonatomic
-#else
- #define NS_NONATOMIC_IOSONLY atomic
-#endif
-
-typedef char BOOL;
- at class NSString;
- at protocol NSCopying @end
-
- at interface NSObject <NSCopying>
- at end
-
- at interface NSDictionary : NSObject
- at end
-
- at interface I : NSObject {
- int ivarVal;
-}
-- (void) setWeakProp : (NSString *__weak)Val;
-- (NSString *__weak) WeakProp;
-
-- (NSString *) StrongProp;
-- (void) setStrongProp : (NSString *)Val;
-
-- (NSString *) UnavailProp __attribute__((unavailable));
-- (void) setUnavailProp : (NSString *)Val;
-
-- (NSString *) UnavailProp1 __attribute__((unavailable));
-- (void) setUnavailProp1 : (NSString *)Val __attribute__((unavailable));
-
-- (NSString *) UnavailProp2;
-- (void) setUnavailProp2 : (NSString *)Val __attribute__((unavailable));
-
-- (NSDictionary*) undoAction;
-- (void) setUndoAction: (NSDictionary*)Arg;
- at end
-
- at implementation I
- at end
-
- at class NSArray;
-
- at interface MyClass2 {
- at private
- NSArray *_names1;
- NSArray *_names2;
- NSArray *_names3;
- NSArray *_names4;
-}
-- (void)setNames1:(NSArray *)names;
-- (void)setNames4:(__strong NSArray *)names;
-- (void)setNames3:(__strong NSArray *)names;
-- (void)setNames2:(NSArray *)names;
-- (NSArray *) names2;
-- (NSArray *)names3;
-- (__strong NSArray *)names4;
-- (NSArray *) names1;
- at end
-
-// Properties that contain the name "delegate" or "dataSource",
-// or have exact name "target" have unsafe_unretained attribute.
- at interface NSInvocation
-- (id)target;
-- (void)setTarget:(id)target;
-
-- (id) dataSource;
-
-- (id)xxxdelegateYYY;
-- (void)setXxxdelegateYYY:(id)delegate;
-
-- (void)setDataSource:(id)source;
-
-- (id)MYtarget;
-- (void)setMYtarget: (id)target;
-
-- (id)targetX;
-- (void)setTargetX: (id)t;
-
-- (int)value;
-- (void)setValue: (int)val;
-
--(BOOL) isContinuous;
--(void) setContinuous:(BOOL)value;
-
-- (id) isAnObject;
-- (void)setAnObject : (id) object;
-
-- (BOOL) isinValid;
-- (void) setInValid : (BOOL) arg;
-
-- (void) Nothing;
-- (int) Length;
-- (id) object;
-+ (double) D;
-- (void *)JSObject WEBKIT_OBJC_METHOD_ANNOTATION(AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER);
-- (BOOL)isIgnoringInteractionEvents;
-
-- (NSString *)getStringValue;
-- (BOOL)getCounterValue;
-- (void)setStringValue:(NSString *)stringValue AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER;
-- (NSDictionary *)getns_dixtionary;
-
-- (BOOL)is3bar; // watch out
-- (NSString *)get3foo; // watch out
-
-- (BOOL) getM;
-- (BOOL) getMA;
-- (BOOL) getALL;
-- (BOOL) getMANY;
-- (BOOL) getSome;
- at end
-
-
- at interface NSInvocation(CAT)
-- (id)target;
-- (void)setTarget:(id)target;
-
-- (id) dataSource;
-
-- (id)xxxdelegateYYY;
-- (void)setXxxdelegateYYY:(id)delegate;
-
-- (void)setDataSource:(id)source;
-
-- (id)MYtarget;
-- (void)setMYtarget: (id)target;
-
-- (id)targetX;
-- (void)setTargetX: (id)t;
-
-- (int)value;
-- (void)setValue: (int)val;
-
--(BOOL) isContinuous;
--(void) setContinuous:(BOOL)value;
-
-- (id) isAnObject;
-- (void)setAnObject : (id) object;
-
-- (BOOL) isinValid;
-- (void) setInValid : (BOOL) arg;
-
-- (void) Nothing;
-- (int) Length;
-- (id) object;
-+ (double) D;
-
-- (BOOL)is3bar; // watch out
-- (NSString *)get3foo; // watch out
-
-- (BOOL) getM;
-- (BOOL) getMA;
-- (BOOL) getALL;
-- (BOOL) getMANY;
-- (BOOL) getSome;
- at end
-
-DEPRECATED
- at interface I_DEP
-- (BOOL) isinValid;
-- (void) setInValid : (BOOL) arg;
- at end
-
- at interface AnotherOne
-- (BOOL) isinValid DEPRECATED;
-- (void) setInValid : (BOOL) arg;
-- (id)MYtarget;
-- (void)setMYtarget: (id)target DEPRECATED;
-- (BOOL) getM DEPRECATED;
-
-- (id)xxxdelegateYYY DEPRECATED;
-- (void)setXxxdelegateYYY:(id)delegate DEPRECATED;
- at end
-
-#define NS_AVAILABLE __attribute__((availability(macosx,introduced=10.0)))
-#define NORETURN __attribute__((noreturn))
-#define ALIGNED __attribute__((aligned(16)))
-
- at interface NSURL
-// Do not infer a property.
-- (NSURL *)appStoreReceiptURL NS_AVAILABLE;
-- (void) setAppStoreReceiptURL : (NSURL *)object;
-
-- (NSURL *)appStoreReceiptURLX NS_AVAILABLE;
-- (void) setAppStoreReceiptURLX : (NSURL *)object NS_AVAILABLE;
-
-// Do not infer a property.
-- (NSURL *)appStoreReceiptURLY ;
-- (void) setAppStoreReceiptURLY : (NSURL *)object NS_AVAILABLE;
-
-- (id)OkToInfer NS_AVAILABLE;
-
-// Do not infer a property.
-- (NSURL *)appStoreReceiptURLZ ;
-- (void) setAppStoreReceiptURLZ : (NSURL *)object NS_AVAILABLE;
-
-// Do not infer a property.
-- (id) t1 NORETURN NS_AVAILABLE;
-- (void) setT1 : (id) arg NS_AVAILABLE;
-
-- (id)method1 ALIGNED NS_AVAILABLE;
-- (void) setMethod1 : (id) object NS_AVAILABLE ALIGNED;
-
-- (NSURL *)init; // No Change
-+ (id)alloc; // No Change
-
-- (BOOL)is1stClass; // Not a valid property
-- (BOOL)isClass; // This is a valid property 'class' is not a keyword in ObjC
-- (BOOL)isDouble; // Not a valid property
-
- at end
-
- at class NSMutableDictionary;
-
- at interface NSArray
-- (id (^)(id, NSArray *, NSMutableDictionary *)) expressionBlock;
-- (id (^)(id, NSArray *, NSMutableDictionary *)) MyBlock;
-- (void) setMyBlock : (id (^)(id, NSArray *, NSMutableDictionary *)) bl;
-- (id (*)(id, NSArray *, NSMutableDictionary *)) expressionFuncptr;
-- (id (*)(id, NSArray *, NSMutableDictionary *)) MyFuncptr;
-- (void) setMyFuncptr : (id (*)(id, NSArray *, NSMutableDictionary *)) bl;
- at end
diff --git a/clang/test/ARCMT/objcmt-ns-nonatomic-iosonly.m.result b/clang/test/ARCMT/objcmt-ns-nonatomic-iosonly.m.result
deleted file mode 100644
index 512deb12583a99..00000000000000
--- a/clang/test/ARCMT/objcmt-ns-nonatomic-iosonly.m.result
+++ /dev/null
@@ -1,206 +0,0 @@
-// RUN: rm -rf %t
-// RUN: %clang_cc1 -fblocks -objcmt-migrate-readwrite-property -objcmt-ns-nonatomic-iosonly -objcmt-migrate-readonly-property -objcmt-atomic-property -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11
-// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result
-// RUN: %clang_cc1 -fblocks -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c -fobjc-runtime-has-weak -fobjc-arc %s.result
-
-#define WEBKIT_OBJC_METHOD_ANNOTATION(ANNOTATION) ANNOTATION
-#define WEAK_IMPORT_ATTRIBUTE __attribute__((objc_arc_weak_reference_unavailable))
-#define AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER
-#define DEPRECATED __attribute__((deprecated))
-
-#if TARGET_OS_IPHONE
- #define NS_NONATOMIC_IOSONLY nonatomic
-#else
- #define NS_NONATOMIC_IOSONLY atomic
-#endif
-
-typedef char BOOL;
- at class NSString;
- at protocol NSCopying @end
-
- at interface NSObject <NSCopying>
- at end
-
- at interface NSDictionary : NSObject
- at end
-
- at interface I : NSObject {
- int ivarVal;
-}
- at property (NS_NONATOMIC_IOSONLY, weak) NSString *WeakProp;
-
- at property (NS_NONATOMIC_IOSONLY, strong) NSString *StrongProp;
-
- at property (NS_NONATOMIC_IOSONLY, strong) NSString *UnavailProp __attribute__((unavailable));
-- (void) setUnavailProp : (NSString *)Val;
-
- at property (NS_NONATOMIC_IOSONLY, strong) NSString *UnavailProp1 __attribute__((unavailable));
-
- at property (NS_NONATOMIC_IOSONLY, strong) NSString *UnavailProp2;
-- (void) setUnavailProp2 : (NSString *)Val __attribute__((unavailable));
-
- at property (NS_NONATOMIC_IOSONLY, copy) NSDictionary *undoAction;
- at end
-
- at implementation I
- at end
-
- at class NSArray;
-
- at interface MyClass2 {
- at private
- NSArray *_names1;
- NSArray *_names2;
- NSArray *_names3;
- NSArray *_names4;
-}
- at property (NS_NONATOMIC_IOSONLY, strong) NSArray *names2;
- at property (NS_NONATOMIC_IOSONLY, strong) NSArray *names3;
- at property (NS_NONATOMIC_IOSONLY, strong) NSArray *names4;
- at property (NS_NONATOMIC_IOSONLY, strong) NSArray *names1;
- at end
-
-// Properties that contain the name "delegate" or "dataSource",
-// or have exact name "target" have unsafe_unretained attribute.
- at interface NSInvocation
- at property (NS_NONATOMIC_IOSONLY, assign) id target;
-
- at property (NS_NONATOMIC_IOSONLY, assign) id dataSource;
-
- at property (NS_NONATOMIC_IOSONLY, assign) id xxxdelegateYYY;
-
-
- at property (NS_NONATOMIC_IOSONLY, strong) id MYtarget;
-
- at property (NS_NONATOMIC_IOSONLY, strong) id targetX;
-
- at property (NS_NONATOMIC_IOSONLY) int value;
-
- at property (NS_NONATOMIC_IOSONLY, getter=isContinuous) BOOL continuous;
-
-- (id) isAnObject;
-- (void)setAnObject : (id) object;
-
- at property (NS_NONATOMIC_IOSONLY, getter=isinValid, readonly) BOOL inValid;
-- (void) setInValid : (BOOL) arg;
-
-- (void) Nothing;
- at property (NS_NONATOMIC_IOSONLY, readonly) int Length;
- at property (NS_NONATOMIC_IOSONLY, readonly, strong) id object;
-+ (double) D;
- at property (NS_NONATOMIC_IOSONLY, readonly) void *JSObject WEBKIT_OBJC_METHOD_ANNOTATION(AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER);
- at property (NS_NONATOMIC_IOSONLY, getter=isIgnoringInteractionEvents, readonly) BOOL ignoringInteractionEvents;
-
- at property (NS_NONATOMIC_IOSONLY, getter=getStringValue, strong) NSString *stringValue;
- at property (NS_NONATOMIC_IOSONLY, getter=getCounterValue, readonly) BOOL counterValue;
- at property (NS_NONATOMIC_IOSONLY, getter=getns_dixtionary, readonly, copy) NSDictionary *ns_dixtionary;
-
-- (BOOL)is3bar; // watch out
-- (NSString *)get3foo; // watch out
-
- at property (NS_NONATOMIC_IOSONLY, getter=getM, readonly) BOOL m;
- at property (NS_NONATOMIC_IOSONLY, getter=getMA, readonly) BOOL MA;
- at property (NS_NONATOMIC_IOSONLY, getter=getALL, readonly) BOOL ALL;
- at property (NS_NONATOMIC_IOSONLY, getter=getMANY, readonly) BOOL MANY;
- at property (NS_NONATOMIC_IOSONLY, getter=getSome, readonly) BOOL some;
- at end
-
-
- at interface NSInvocation(CAT)
- at property (NS_NONATOMIC_IOSONLY, assign) id target;
-
- at property (NS_NONATOMIC_IOSONLY, assign) id dataSource;
-
- at property (NS_NONATOMIC_IOSONLY, assign) id xxxdelegateYYY;
-
-
- at property (NS_NONATOMIC_IOSONLY, strong) id MYtarget;
-
- at property (NS_NONATOMIC_IOSONLY, strong) id targetX;
-
- at property (NS_NONATOMIC_IOSONLY) int value;
-
- at property (NS_NONATOMIC_IOSONLY, getter=isContinuous) BOOL continuous;
-
-- (id) isAnObject;
-- (void)setAnObject : (id) object;
-
- at property (NS_NONATOMIC_IOSONLY, getter=isinValid, readonly) BOOL inValid;
-- (void) setInValid : (BOOL) arg;
-
-- (void) Nothing;
- at property (NS_NONATOMIC_IOSONLY, readonly) int Length;
- at property (NS_NONATOMIC_IOSONLY, readonly, strong) id object;
-+ (double) D;
-
-- (BOOL)is3bar; // watch out
-- (NSString *)get3foo; // watch out
-
- at property (NS_NONATOMIC_IOSONLY, getter=getM, readonly) BOOL m;
- at property (NS_NONATOMIC_IOSONLY, getter=getMA, readonly) BOOL MA;
- at property (NS_NONATOMIC_IOSONLY, getter=getALL, readonly) BOOL ALL;
- at property (NS_NONATOMIC_IOSONLY, getter=getMANY, readonly) BOOL MANY;
- at property (NS_NONATOMIC_IOSONLY, getter=getSome, readonly) BOOL some;
- at end
-
-DEPRECATED
- at interface I_DEP
-- (BOOL) isinValid;
-- (void) setInValid : (BOOL) arg;
- at end
-
- at interface AnotherOne
-- (BOOL) isinValid DEPRECATED;
-- (void) setInValid : (BOOL) arg;
-- (id)MYtarget;
-- (void)setMYtarget: (id)target DEPRECATED;
-- (BOOL) getM DEPRECATED;
-
-- (id)xxxdelegateYYY DEPRECATED;
-- (void)setXxxdelegateYYY:(id)delegate DEPRECATED;
- at end
-
-#define NS_AVAILABLE __attribute__((availability(macosx,introduced=10.0)))
-#define NORETURN __attribute__((noreturn))
-#define ALIGNED __attribute__((aligned(16)))
-
- at interface NSURL
-// Do not infer a property.
- at property (NS_NONATOMIC_IOSONLY, strong) NSURL *appStoreReceiptURL NS_AVAILABLE;
-- (void) setAppStoreReceiptURL : (NSURL *)object;
-
- at property (NS_NONATOMIC_IOSONLY, strong) NSURL *appStoreReceiptURLX NS_AVAILABLE;
-
-// Do not infer a property.
- at property (NS_NONATOMIC_IOSONLY, strong) NSURL *appStoreReceiptURLY ;
-- (void) setAppStoreReceiptURLY : (NSURL *)object NS_AVAILABLE;
-
- at property (NS_NONATOMIC_IOSONLY, readonly, strong) id OkToInfer NS_AVAILABLE;
-
-// Do not infer a property.
- at property (NS_NONATOMIC_IOSONLY, strong) NSURL *appStoreReceiptURLZ ;
-- (void) setAppStoreReceiptURLZ : (NSURL *)object NS_AVAILABLE;
-
-// Do not infer a property.
-- (id) t1 NORETURN NS_AVAILABLE;
-- (void) setT1 : (id) arg NS_AVAILABLE;
-
- at property (NS_NONATOMIC_IOSONLY, strong) id method1 ALIGNED NS_AVAILABLE;
-
-- (NSURL *)init; // No Change
-+ (id)alloc; // No Change
-
-- (BOOL)is1stClass; // Not a valid property
- at property (NS_NONATOMIC_IOSONLY, getter=isClass, readonly) BOOL class; // This is a valid property 'class' is not a keyword in ObjC
-- (BOOL)isDouble; // Not a valid property
-
- at end
-
- at class NSMutableDictionary;
-
- at interface NSArray
- at property (NS_NONATOMIC_IOSONLY, readonly, copy) id (^expressionBlock)(id, NSArray *, NSMutableDictionary *);
- at property (NS_NONATOMIC_IOSONLY, copy) id (^MyBlock)(id, NSArray *, NSMutableDictionary *);
- at property (NS_NONATOMIC_IOSONLY, readonly) id (*expressionFuncptr)(id, NSArray *, NSMutableDictionary *);
- at property (NS_NONATOMIC_IOSONLY) id (*MyFuncptr)(id, NSArray *, NSMutableDictionary *);
- at end
diff --git a/clang/test/ARCMT/objcmt-ns-returns-inner-pointer.m b/clang/test/ARCMT/objcmt-ns-returns-inner-pointer.m
deleted file mode 100644
index 853d16dc789420..00000000000000
--- a/clang/test/ARCMT/objcmt-ns-returns-inner-pointer.m
+++ /dev/null
@@ -1,128 +0,0 @@
-// RUN: rm -rf %t
-// RUN: %clang_cc1 -objcmt-returns-innerpointer-property -objcmt-migrate-annotation -objcmt-migrate-readwrite-property -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11
-// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c -fobjc-runtime-has-weak -fobjc-arc %s.result
-
-#ifndef NS_RETURNS_INNER_POINTER // defined in iOS 6 for sure
-#define NS_RETURNS_INNER_POINTER __attribute__((objc_returns_inner_pointer))
-#endif
-
-#define CF_IMPLICIT_BRIDGING_ENABLED _Pragma("clang arc_cf_code_audited begin")
-
-#define CF_IMPLICIT_BRIDGING_DISABLED _Pragma("clang arc_cf_code_audited end")
-
-#if __has_feature(attribute_ns_returns_retained)
-#define NS_RETURNS_RETAINED __attribute__((ns_returns_retained))
-#endif
-#if __has_feature(attribute_cf_returns_retained)
-#define CF_RETURNS_RETAINED __attribute__((cf_returns_retained))
-#endif
-#if __has_feature(attribute_ns_returns_not_retained)
-#define NS_RETURNS_NOT_RETAINED __attribute__((ns_returns_not_retained))
-#endif
-#if __has_feature(attribute_cf_returns_not_retained)
-#define CF_RETURNS_NOT_RETAINED __attribute__((cf_returns_not_retained))
-#endif
-#if __has_feature(attribute_ns_consumes_self)
-#define NS_CONSUMES_SELF __attribute__((ns_consumes_self))
-#endif
-#if __has_feature(attribute_ns_consumed)
-#define NS_CONSUMED __attribute__((ns_consumed))
-#endif
-#if __has_feature(attribute_cf_consumed)
-#define CF_CONSUMED __attribute__((cf_consumed))
-#endif
-#if __has_attribute(ns_returns_autoreleased)
-#define NS_RETURNS_AUTORELEASED __attribute__((ns_returns_autoreleased))
-#endif
-
-#define NS_AVAILABLE __attribute__((availability(macosx,introduced=10.0)))
-
-CF_IMPLICIT_BRIDGING_ENABLED
-
-typedef unsigned long CFTypeID;
-typedef unsigned long CFOptionFlags;
-typedef unsigned long CFHashCode;
-
-typedef signed long CFIndex; /*AnyObj*/
-typedef const struct __CFArray * CFArrayRef;
-typedef struct {
- CFIndex location;
- CFIndex length;
-} CFRange;
-
-typedef void (*CFArrayApplierFunction)(const void *value, void *context);
-
-typedef enum CFComparisonResult : CFIndex CFComparisonResult; enum CFComparisonResult : CFIndex {
- kCFCompareLessThan = -1L,
- kCFCompareEqualTo = 0,
- kCFCompareGreaterThan = 1
-};
-
-
-typedef CFComparisonResult (*CFComparatorFunction)(const void *val1, const void *val2, void *context);
-
-typedef struct __CFArray * CFMutableArrayRef;
-
-typedef const struct __CFAttributedString *CFAttributedStringRef;
-typedef struct __CFAttributedString *CFMutableAttributedStringRef;
-
-typedef const struct __CFAllocator * CFAllocatorRef;
-
-typedef const struct __CFString * CFStringRef;
-typedef struct __CFString * CFMutableStringRef;
-
-typedef const struct __CFDictionary * CFDictionaryRef;
-typedef struct __CFDictionary * CFMutableDictionaryRef;
-
-typedef struct CGImage *CGImageRef;
-
-typedef struct OpaqueJSValue* JSObjectRef;
-
-typedef JSObjectRef TTJSObjectRef;
-typedef unsigned int NSUInteger;
-
-CF_IMPLICIT_BRIDGING_DISABLED
-
- at interface I
-- (void*) ReturnsInnerPointer;
-- (int*) AlreadyReturnsInnerPointer NS_RETURNS_INNER_POINTER;
- at end
-
- at interface UIImage
-- (CGImageRef)CGImage;
- at end
-
- at interface NSData
-- (void *)bytes;
-- (void **) ptr_bytes __attribute__((availability(macosx,unavailable)));
- at end
-
- at interface NSMutableData
-- (void *)mutableBytes __attribute__((deprecated)) __attribute__((unavailable));
- at end
-
- at interface JS
-- (JSObjectRef)JSObject;
-- (TTJSObjectRef)JSObject1;
-- (JSObjectRef*)JSObject2;
- at end
-
-typedef void *SecTrustRef;
-
- at interface NSURLProtectionSpace
- at property (readonly) SecTrustRef serverTrust NS_AVAILABLE;
-- (void *) FOO NS_AVAILABLE;
- at property (readonly) void * mitTrust NS_AVAILABLE;
-
- at property (readonly) void * mittiTrust;
-
- at property (readonly) SecTrustRef XserverTrust;
-
-- (SecTrustRef) FOO1 NS_AVAILABLE;
-
-+ (const NSURLProtectionSpace *)ProtectionSpace;
-
-// pointer personality functions
- at property NSUInteger (*hashFunction)(const void *item, NSUInteger (*size)(const void *item));
- at end
diff --git a/clang/test/ARCMT/objcmt-ns-returns-inner-pointer.m.result b/clang/test/ARCMT/objcmt-ns-returns-inner-pointer.m.result
deleted file mode 100644
index c89c91eedce35f..00000000000000
--- a/clang/test/ARCMT/objcmt-ns-returns-inner-pointer.m.result
+++ /dev/null
@@ -1,128 +0,0 @@
-// RUN: rm -rf %t
-// RUN: %clang_cc1 -objcmt-returns-innerpointer-property -objcmt-migrate-annotation -objcmt-migrate-readwrite-property -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11
-// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c -fobjc-runtime-has-weak -fobjc-arc %s.result
-
-#ifndef NS_RETURNS_INNER_POINTER // defined in iOS 6 for sure
-#define NS_RETURNS_INNER_POINTER __attribute__((objc_returns_inner_pointer))
-#endif
-
-#define CF_IMPLICIT_BRIDGING_ENABLED _Pragma("clang arc_cf_code_audited begin")
-
-#define CF_IMPLICIT_BRIDGING_DISABLED _Pragma("clang arc_cf_code_audited end")
-
-#if __has_feature(attribute_ns_returns_retained)
-#define NS_RETURNS_RETAINED __attribute__((ns_returns_retained))
-#endif
-#if __has_feature(attribute_cf_returns_retained)
-#define CF_RETURNS_RETAINED __attribute__((cf_returns_retained))
-#endif
-#if __has_feature(attribute_ns_returns_not_retained)
-#define NS_RETURNS_NOT_RETAINED __attribute__((ns_returns_not_retained))
-#endif
-#if __has_feature(attribute_cf_returns_not_retained)
-#define CF_RETURNS_NOT_RETAINED __attribute__((cf_returns_not_retained))
-#endif
-#if __has_feature(attribute_ns_consumes_self)
-#define NS_CONSUMES_SELF __attribute__((ns_consumes_self))
-#endif
-#if __has_feature(attribute_ns_consumed)
-#define NS_CONSUMED __attribute__((ns_consumed))
-#endif
-#if __has_feature(attribute_cf_consumed)
-#define CF_CONSUMED __attribute__((cf_consumed))
-#endif
-#if __has_attribute(ns_returns_autoreleased)
-#define NS_RETURNS_AUTORELEASED __attribute__((ns_returns_autoreleased))
-#endif
-
-#define NS_AVAILABLE __attribute__((availability(macosx,introduced=10.0)))
-
-CF_IMPLICIT_BRIDGING_ENABLED
-
-typedef unsigned long CFTypeID;
-typedef unsigned long CFOptionFlags;
-typedef unsigned long CFHashCode;
-
-typedef signed long CFIndex; /*AnyObj*/
-typedef const struct __CFArray * CFArrayRef;
-typedef struct {
- CFIndex location;
- CFIndex length;
-} CFRange;
-
-typedef void (*CFArrayApplierFunction)(const void *value, void *context);
-
-typedef enum CFComparisonResult : CFIndex CFComparisonResult; enum CFComparisonResult : CFIndex {
- kCFCompareLessThan = -1L,
- kCFCompareEqualTo = 0,
- kCFCompareGreaterThan = 1
-};
-
-
-typedef CFComparisonResult (*CFComparatorFunction)(const void *val1, const void *val2, void *context);
-
-typedef struct __CFArray * CFMutableArrayRef;
-
-typedef const struct __CFAttributedString *CFAttributedStringRef;
-typedef struct __CFAttributedString *CFMutableAttributedStringRef;
-
-typedef const struct __CFAllocator * CFAllocatorRef;
-
-typedef const struct __CFString * CFStringRef;
-typedef struct __CFString * CFMutableStringRef;
-
-typedef const struct __CFDictionary * CFDictionaryRef;
-typedef struct __CFDictionary * CFMutableDictionaryRef;
-
-typedef struct CGImage *CGImageRef;
-
-typedef struct OpaqueJSValue* JSObjectRef;
-
-typedef JSObjectRef TTJSObjectRef;
-typedef unsigned int NSUInteger;
-
-CF_IMPLICIT_BRIDGING_DISABLED
-
- at interface I
-- (void*) ReturnsInnerPointer NS_RETURNS_INNER_POINTER;
-- (int*) AlreadyReturnsInnerPointer NS_RETURNS_INNER_POINTER;
- at end
-
- at interface UIImage
-- (CGImageRef)CGImage CF_RETURNS_NOT_RETAINED;
- at end
-
- at interface NSData
-- (void *)bytes NS_RETURNS_INNER_POINTER;
-- (void **) ptr_bytes __attribute__((availability(macosx,unavailable))) NS_RETURNS_INNER_POINTER;
- at end
-
- at interface NSMutableData
-- (void *)mutableBytes __attribute__((deprecated)) __attribute__((unavailable)) NS_RETURNS_INNER_POINTER;
- at end
-
- at interface JS
-- (JSObjectRef)JSObject;
-- (TTJSObjectRef)JSObject1;
-- (JSObjectRef*)JSObject2 NS_RETURNS_INNER_POINTER;
- at end
-
-typedef void *SecTrustRef;
-
- at interface NSURLProtectionSpace
- at property (readonly) SecTrustRef NS_RETURNS_INNER_POINTER serverTrust NS_AVAILABLE;
-- (void *) FOO NS_AVAILABLE NS_RETURNS_INNER_POINTER;
- at property (readonly) void * NS_RETURNS_INNER_POINTER mitTrust NS_AVAILABLE;
-
- at property (readonly) void * NS_RETURNS_INNER_POINTER mittiTrust;
-
- at property (readonly) SecTrustRef NS_RETURNS_INNER_POINTER XserverTrust;
-
-- (SecTrustRef) FOO1 NS_AVAILABLE NS_RETURNS_INNER_POINTER;
-
-+ (const NSURLProtectionSpace *)ProtectionSpace;
-
-// pointer personality functions
- at property NSUInteger (*hashFunction)(const void *item, NSUInteger (*size)(const void *item));
- at end
diff --git a/clang/test/ARCMT/objcmt-numeric-literals.m b/clang/test/ARCMT/objcmt-numeric-literals.m
deleted file mode 100644
index 7f33dc27997e1d..00000000000000
--- a/clang/test/ARCMT/objcmt-numeric-literals.m
+++ /dev/null
@@ -1,502 +0,0 @@
-// RUN: rm -rf %t
-// RUN: %clang_cc1 -objcmt-migrate-literals -objcmt-migrate-subscripting -mt-migrate-directory %t %s -x objective-c++
-// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c++ %s.result
-
-#define YES __objc_yes
-#define NO __objc_no
-
-typedef long NSInteger;
-typedef unsigned long NSUInteger;
-typedef signed char BOOL;
-#define nil ((void*) 0)
-
- at interface NSObject
-+ (id)alloc;
- at end
-
- at interface NSNumber : NSObject
- at end
-
- at interface NSNumber (NSNumberCreation)
-- (id)initWithChar:(char)value;
-- (id)initWithUnsignedChar:(unsigned char)value;
-- (id)initWithShort:(short)value;
-- (id)initWithUnsignedShort:(unsigned short)value;
-- (id)initWithInt:(int)value;
-- (id)initWithUnsignedInt:(unsigned int)value;
-- (id)initWithLong:(long)value;
-- (id)initWithUnsignedLong:(unsigned long)value;
-- (id)initWithLongLong:(long long)value;
-- (id)initWithUnsignedLongLong:(unsigned long long)value;
-- (id)initWithFloat:(float)value;
-- (id)initWithDouble:(double)value;
-- (id)initWithBool:(BOOL)value;
-- (id)initWithInteger:(NSInteger)value;
-- (id)initWithUnsignedInteger:(NSUInteger)value;
-
-+ (NSNumber *)numberWithChar:(char)value;
-+ (NSNumber *)numberWithUnsignedChar:(unsigned char)value;
-+ (NSNumber *)numberWithShort:(short)value;
-+ (NSNumber *)numberWithUnsignedShort:(unsigned short)value;
-+ (NSNumber *)numberWithInt:(int)value;
-+ (NSNumber *)numberWithUnsignedInt:(unsigned int)value;
-+ (NSNumber *)numberWithLong:(long)value;
-+ (NSNumber *)numberWithUnsignedLong:(unsigned long)value;
-+ (NSNumber *)numberWithLongLong:(long long)value;
-+ (NSNumber *)numberWithUnsignedLongLong:(unsigned long long)value;
-+ (NSNumber *)numberWithFloat:(float)value;
-+ (NSNumber *)numberWithDouble:(double)value;
-+ (NSNumber *)numberWithBool:(BOOL)value;
-+ (NSNumber *)numberWithInteger:(NSInteger)value;
-+ (NSNumber *)numberWithUnsignedInteger:(NSUInteger)value;
- at end
-
-#define VAL_INT 2
-#define VAL_UINT 2U
-#define VAL_CHAR 'a'
-
-void foo() {
- [NSNumber numberWithChar:'a'];
- [NSNumber numberWithChar:L'a'];
- [NSNumber numberWithChar:2];
- [NSNumber numberWithChar:2U];
- [NSNumber numberWithChar:2u];
- [NSNumber numberWithChar:2L];
- [NSNumber numberWithChar:2l];
- [NSNumber numberWithChar:2LL];
- [NSNumber numberWithChar:2ll];
- [NSNumber numberWithChar:2ul];
- [NSNumber numberWithChar:2lu];
- [NSNumber numberWithChar:2ull];
- [NSNumber numberWithChar:2llu];
- [NSNumber numberWithChar:2.0];
- [NSNumber numberWithChar:2.0f];
- [NSNumber numberWithChar:2.0F];
- [NSNumber numberWithChar:2.0l];
- [NSNumber numberWithChar:2.0L];
- [NSNumber numberWithChar:0x2f];
- [NSNumber numberWithChar:04];
- [NSNumber numberWithChar:0];
- [NSNumber numberWithChar:0.0];
- [NSNumber numberWithChar:YES];
- [NSNumber numberWithChar:NO];
- [NSNumber numberWithChar:true];
- [NSNumber numberWithChar:false];
- [NSNumber numberWithChar:VAL_INT];
- [NSNumber numberWithChar:VAL_UINT];
- [NSNumber numberWithChar:VAL_CHAR];
-
- [NSNumber numberWithUnsignedChar:'a'];
- [NSNumber numberWithUnsignedChar:L'a'];
- [NSNumber numberWithUnsignedChar:2];
- [NSNumber numberWithUnsignedChar:2U];
- [NSNumber numberWithUnsignedChar:2u];
- [NSNumber numberWithUnsignedChar:2L];
- [NSNumber numberWithUnsignedChar:2l];
- [NSNumber numberWithUnsignedChar:2LL];
- [NSNumber numberWithUnsignedChar:2ll];
- [NSNumber numberWithUnsignedChar:2ul];
- [NSNumber numberWithUnsignedChar:2lu];
- [NSNumber numberWithUnsignedChar:2ull];
- [NSNumber numberWithUnsignedChar:2llu];
- [NSNumber numberWithUnsignedChar:2.0];
- [NSNumber numberWithUnsignedChar:2.0f];
- [NSNumber numberWithUnsignedChar:2.0F];
- [NSNumber numberWithUnsignedChar:2.0l];
- [NSNumber numberWithUnsignedChar:2.0L];
- [NSNumber numberWithUnsignedChar:0x2f];
- [NSNumber numberWithUnsignedChar:04];
- [NSNumber numberWithUnsignedChar:0];
- [NSNumber numberWithUnsignedChar:0.0];
- [NSNumber numberWithUnsignedChar:YES];
- [NSNumber numberWithUnsignedChar:NO];
- [NSNumber numberWithUnsignedChar:true];
- [NSNumber numberWithUnsignedChar:false];
- [NSNumber numberWithUnsignedChar:VAL_INT];
- [NSNumber numberWithUnsignedChar:VAL_UINT];
- [NSNumber numberWithUnsignedChar:VAL_CHAR];
-
- [NSNumber numberWithShort:'a'];
- [NSNumber numberWithShort:L'a'];
- [NSNumber numberWithShort:2];
- [NSNumber numberWithShort:2U];
- [NSNumber numberWithShort:2u];
- [NSNumber numberWithShort:2L];
- [NSNumber numberWithShort:2l];
- [NSNumber numberWithShort:2LL];
- [NSNumber numberWithShort:2ll];
- [NSNumber numberWithShort:2ul];
- [NSNumber numberWithShort:2lu];
- [NSNumber numberWithShort:2ull];
- [NSNumber numberWithShort:2llu];
- [NSNumber numberWithShort:2.0];
- [NSNumber numberWithShort:2.0f];
- [NSNumber numberWithShort:2.0F];
- [NSNumber numberWithShort:2.0l];
- [NSNumber numberWithShort:2.0L];
- [NSNumber numberWithShort:0x2f];
- [NSNumber numberWithShort:04];
- [NSNumber numberWithShort:0];
- [NSNumber numberWithShort:0.0];
- [NSNumber numberWithShort:YES];
- [NSNumber numberWithShort:NO];
- [NSNumber numberWithShort:true];
- [NSNumber numberWithShort:false];
- [NSNumber numberWithShort:VAL_INT];
- [NSNumber numberWithShort:VAL_UINT];
-
- [NSNumber numberWithUnsignedShort:'a'];
- [NSNumber numberWithUnsignedShort:L'a'];
- [NSNumber numberWithUnsignedShort:2];
- [NSNumber numberWithUnsignedShort:2U];
- [NSNumber numberWithUnsignedShort:2u];
- [NSNumber numberWithUnsignedShort:2L];
- [NSNumber numberWithUnsignedShort:2l];
- [NSNumber numberWithUnsignedShort:2LL];
- [NSNumber numberWithUnsignedShort:2ll];
- [NSNumber numberWithUnsignedShort:2ul];
- [NSNumber numberWithUnsignedShort:2lu];
- [NSNumber numberWithUnsignedShort:2ull];
- [NSNumber numberWithUnsignedShort:2llu];
- [NSNumber numberWithUnsignedShort:2.0];
- [NSNumber numberWithUnsignedShort:2.0f];
- [NSNumber numberWithUnsignedShort:2.0F];
- [NSNumber numberWithUnsignedShort:2.0l];
- [NSNumber numberWithUnsignedShort:2.0L];
- [NSNumber numberWithUnsignedShort:0x2f];
- [NSNumber numberWithUnsignedShort:04];
- [NSNumber numberWithUnsignedShort:0];
- [NSNumber numberWithUnsignedShort:0.0];
- [NSNumber numberWithUnsignedShort:YES];
- [NSNumber numberWithUnsignedShort:NO];
- [NSNumber numberWithUnsignedShort:true];
- [NSNumber numberWithUnsignedShort:false];
- [NSNumber numberWithUnsignedShort:VAL_INT];
- [NSNumber numberWithUnsignedShort:VAL_UINT];
-
- [NSNumber numberWithInt:'a'];
- [NSNumber numberWithInt:L'a'];
- [NSNumber numberWithInt:2];
- [NSNumber numberWithInt:2U];
- [NSNumber numberWithInt:2u];
- [NSNumber numberWithInt:2L];
- [NSNumber numberWithInt:2l];
- [NSNumber numberWithInt:2LL];
- [NSNumber numberWithInt:2ll];
- [NSNumber numberWithInt:2ul];
- [NSNumber numberWithInt:2lu];
- [NSNumber numberWithInt:2ull];
- [NSNumber numberWithInt:2llu];
- [NSNumber numberWithInt:2.0];
- [NSNumber numberWithInt:2.0f];
- [NSNumber numberWithInt:2.0F];
- [NSNumber numberWithInt:2.0l];
- [NSNumber numberWithInt:2.0L];
- [NSNumber numberWithInt:0x2f];
- [NSNumber numberWithInt:04];
- [NSNumber numberWithInt:0];
- [NSNumber numberWithInt:0.0];
- [NSNumber numberWithInt:YES];
- [NSNumber numberWithInt:NO];
- [NSNumber numberWithInt:true];
- [NSNumber numberWithInt:false];
- [NSNumber numberWithInt:VAL_INT];
- [NSNumber numberWithInt:VAL_UINT];
-
- (void)[[NSNumber alloc] initWithInt:2];
- (void)[[NSNumber alloc] initWithInt:2U];
-
- [NSNumber numberWithInt:+2];
- [NSNumber numberWithInt:-2];
-
- [NSNumber numberWithUnsignedInt:'a'];
- [NSNumber numberWithUnsignedInt:L'a'];
- [NSNumber numberWithUnsignedInt:2];
- [NSNumber numberWithUnsignedInt:2U];
- [NSNumber numberWithUnsignedInt:2u];
- [NSNumber numberWithUnsignedInt:2L];
- [NSNumber numberWithUnsignedInt:2l];
- [NSNumber numberWithUnsignedInt:2LL];
- [NSNumber numberWithUnsignedInt:2ll];
- [NSNumber numberWithUnsignedInt:2ul];
- [NSNumber numberWithUnsignedInt:2lu];
- [NSNumber numberWithUnsignedInt:2ull];
- [NSNumber numberWithUnsignedInt:2llu];
- [NSNumber numberWithUnsignedInt:2.0];
- [NSNumber numberWithUnsignedInt:2.0f];
- [NSNumber numberWithUnsignedInt:2.0F];
- [NSNumber numberWithUnsignedInt:2.0l];
- [NSNumber numberWithUnsignedInt:2.0L];
- [NSNumber numberWithUnsignedInt:0x2f];
- [NSNumber numberWithUnsignedInt:04];
- [NSNumber numberWithUnsignedInt:0];
- [NSNumber numberWithUnsignedInt:0.0];
- [NSNumber numberWithUnsignedInt:YES];
- [NSNumber numberWithUnsignedInt:NO];
- [NSNumber numberWithUnsignedInt:true];
- [NSNumber numberWithUnsignedInt:false];
- [NSNumber numberWithUnsignedInt:VAL_INT];
- [NSNumber numberWithUnsignedInt:VAL_UINT];
-
- [NSNumber numberWithLong:'a'];
- [NSNumber numberWithLong:L'a'];
- [NSNumber numberWithLong:2];
- [NSNumber numberWithLong:2U];
- [NSNumber numberWithLong:2u];
- [NSNumber numberWithLong:2L];
- [NSNumber numberWithLong:2l];
- [NSNumber numberWithLong:2LL];
- [NSNumber numberWithLong:2ll];
- [NSNumber numberWithLong:2ul];
- [NSNumber numberWithLong:2lu];
- [NSNumber numberWithLong:2ull];
- [NSNumber numberWithLong:2llu];
- [NSNumber numberWithLong:2.0];
- [NSNumber numberWithLong:2.0f];
- [NSNumber numberWithLong:2.0F];
- [NSNumber numberWithLong:2.0l];
- [NSNumber numberWithLong:2.0L];
- [NSNumber numberWithLong:0x2f];
- [NSNumber numberWithLong:04];
- [NSNumber numberWithLong:0];
- [NSNumber numberWithLong:0.0];
- [NSNumber numberWithLong:YES];
- [NSNumber numberWithLong:NO];
- [NSNumber numberWithLong:true];
- [NSNumber numberWithLong:false];
- [NSNumber numberWithLong:VAL_INT];
- [NSNumber numberWithLong:VAL_UINT];
-
- [NSNumber numberWithUnsignedLong:'a'];
- [NSNumber numberWithUnsignedLong:L'a'];
- [NSNumber numberWithUnsignedLong:2];
- [NSNumber numberWithUnsignedLong:2U];
- [NSNumber numberWithUnsignedLong:2u];
- [NSNumber numberWithUnsignedLong:2L];
- [NSNumber numberWithUnsignedLong:2l];
- [NSNumber numberWithUnsignedLong:2LL];
- [NSNumber numberWithUnsignedLong:2ll];
- [NSNumber numberWithUnsignedLong:2ul];
- [NSNumber numberWithUnsignedLong:2lu];
- [NSNumber numberWithUnsignedLong:2ull];
- [NSNumber numberWithUnsignedLong:2llu];
- [NSNumber numberWithUnsignedLong:2.0];
- [NSNumber numberWithUnsignedLong:2.0f];
- [NSNumber numberWithUnsignedLong:2.0F];
- [NSNumber numberWithUnsignedLong:2.0l];
- [NSNumber numberWithUnsignedLong:2.0L];
- [NSNumber numberWithUnsignedLong:0x2f];
- [NSNumber numberWithUnsignedLong:04];
- [NSNumber numberWithUnsignedLong:0];
- [NSNumber numberWithUnsignedLong:0.0];
- [NSNumber numberWithUnsignedLong:YES];
- [NSNumber numberWithUnsignedLong:NO];
- [NSNumber numberWithUnsignedLong:true];
- [NSNumber numberWithUnsignedLong:false];
- [NSNumber numberWithUnsignedLong:VAL_INT];
- [NSNumber numberWithUnsignedLong:VAL_UINT];
-
- [NSNumber numberWithLongLong:'a'];
- [NSNumber numberWithLongLong:L'a'];
- [NSNumber numberWithLongLong:2];
- [NSNumber numberWithLongLong:2U];
- [NSNumber numberWithLongLong:2u];
- [NSNumber numberWithLongLong:2L];
- [NSNumber numberWithLongLong:2l];
- [NSNumber numberWithLongLong:2LL];
- [NSNumber numberWithLongLong:2ll];
- [NSNumber numberWithLongLong:2ul];
- [NSNumber numberWithLongLong:2lu];
- [NSNumber numberWithLongLong:2ull];
- [NSNumber numberWithLongLong:2llu];
- [NSNumber numberWithLongLong:2.0];
- [NSNumber numberWithLongLong:2.0f];
- [NSNumber numberWithLongLong:2.0F];
- [NSNumber numberWithLongLong:2.0l];
- [NSNumber numberWithLongLong:2.0L];
- [NSNumber numberWithLongLong:0x2f];
- [NSNumber numberWithLongLong:04];
- [NSNumber numberWithLongLong:0];
- [NSNumber numberWithLongLong:0.0];
- [NSNumber numberWithLongLong:YES];
- [NSNumber numberWithLongLong:NO];
- [NSNumber numberWithLongLong:true];
- [NSNumber numberWithLongLong:false];
- [NSNumber numberWithLongLong:VAL_INT];
- [NSNumber numberWithLongLong:VAL_UINT];
-
- [NSNumber numberWithUnsignedLongLong:'a'];
- [NSNumber numberWithUnsignedLongLong:L'a'];
- [NSNumber numberWithUnsignedLongLong:2];
- [NSNumber numberWithUnsignedLongLong:2U];
- [NSNumber numberWithUnsignedLongLong:2u];
- [NSNumber numberWithUnsignedLongLong:2L];
- [NSNumber numberWithUnsignedLongLong:2l];
- [NSNumber numberWithUnsignedLongLong:2LL];
- [NSNumber numberWithUnsignedLongLong:2ll];
- [NSNumber numberWithUnsignedLongLong:2ul];
- [NSNumber numberWithUnsignedLongLong:2lu];
- [NSNumber numberWithUnsignedLongLong:2ull];
- [NSNumber numberWithUnsignedLongLong:2llu];
- [NSNumber numberWithUnsignedLongLong:2.0];
- [NSNumber numberWithUnsignedLongLong:2.0f];
- [NSNumber numberWithUnsignedLongLong:2.0F];
- [NSNumber numberWithUnsignedLongLong:2.0l];
- [NSNumber numberWithUnsignedLongLong:2.0L];
- [NSNumber numberWithUnsignedLongLong:0x2f];
- [NSNumber numberWithUnsignedLongLong:04];
- [NSNumber numberWithUnsignedLongLong:0];
- [NSNumber numberWithUnsignedLongLong:0.0];
- [NSNumber numberWithUnsignedLongLong:YES];
- [NSNumber numberWithUnsignedLongLong:NO];
- [NSNumber numberWithUnsignedLongLong:true];
- [NSNumber numberWithUnsignedLongLong:false];
- [NSNumber numberWithUnsignedLongLong:VAL_INT];
- [NSNumber numberWithUnsignedLongLong:VAL_UINT];
-
- [NSNumber numberWithFloat:'a'];
- [NSNumber numberWithFloat:L'a'];
- [NSNumber numberWithFloat:2];
- [NSNumber numberWithFloat:2U];
- [NSNumber numberWithFloat:2u];
- [NSNumber numberWithFloat:2L];
- [NSNumber numberWithFloat:2l];
- [NSNumber numberWithFloat:2LL];
- [NSNumber numberWithFloat:2ll];
- [NSNumber numberWithFloat:2ul];
- [NSNumber numberWithFloat:2lu];
- [NSNumber numberWithFloat:2ull];
- [NSNumber numberWithFloat:2llu];
- [NSNumber numberWithFloat:2.0];
- [NSNumber numberWithFloat:2.0f];
- [NSNumber numberWithFloat:2.0F];
- [NSNumber numberWithFloat:2.0l];
- [NSNumber numberWithFloat:2.0L];
- [NSNumber numberWithFloat:0x2f];
- [NSNumber numberWithFloat:04];
- [NSNumber numberWithFloat:0];
- [NSNumber numberWithFloat:0.0];
- [NSNumber numberWithFloat:YES];
- [NSNumber numberWithFloat:NO];
- [NSNumber numberWithFloat:true];
- [NSNumber numberWithFloat:false];
- [NSNumber numberWithFloat:VAL_INT];
- [NSNumber numberWithFloat:VAL_UINT];
-
- [NSNumber numberWithDouble:'a'];
- [NSNumber numberWithDouble:L'a'];
- [NSNumber numberWithDouble:2];
- [NSNumber numberWithDouble:2U];
- [NSNumber numberWithDouble:2u];
- [NSNumber numberWithDouble:2L];
- [NSNumber numberWithDouble:2l];
- [NSNumber numberWithDouble:2LL];
- [NSNumber numberWithDouble:2ll];
- [NSNumber numberWithDouble:2ul];
- [NSNumber numberWithDouble:2lu];
- [NSNumber numberWithDouble:2ull];
- [NSNumber numberWithDouble:2llu];
- [NSNumber numberWithDouble:2.0];
- [NSNumber numberWithDouble:2.0f];
- [NSNumber numberWithDouble:2.0F];
- [NSNumber numberWithDouble:2.0l];
- [NSNumber numberWithDouble:2.0L];
- [NSNumber numberWithDouble:0x2f];
- [NSNumber numberWithDouble:04];
- [NSNumber numberWithDouble:0];
- [NSNumber numberWithDouble:0.0];
- [NSNumber numberWithDouble:YES];
- [NSNumber numberWithDouble:NO];
- [NSNumber numberWithDouble:true];
- [NSNumber numberWithDouble:false];
- [NSNumber numberWithDouble:VAL_INT];
- [NSNumber numberWithDouble:VAL_UINT];
-
- [NSNumber numberWithBool:'a'];
- [NSNumber numberWithBool:L'a'];
- [NSNumber numberWithBool:2];
- [NSNumber numberWithBool:2U];
- [NSNumber numberWithBool:2u];
- [NSNumber numberWithBool:2L];
- [NSNumber numberWithBool:2l];
- [NSNumber numberWithBool:2LL];
- [NSNumber numberWithBool:2ll];
- [NSNumber numberWithBool:2ul];
- [NSNumber numberWithBool:2lu];
- [NSNumber numberWithBool:2ull];
- [NSNumber numberWithBool:2llu];
- [NSNumber numberWithBool:2.0];
- [NSNumber numberWithBool:2.0f];
- [NSNumber numberWithBool:2.0F];
- [NSNumber numberWithBool:2.0l];
- [NSNumber numberWithBool:2.0L];
- [NSNumber numberWithBool:0x2f];
- [NSNumber numberWithBool:04];
- [NSNumber numberWithBool:0];
- [NSNumber numberWithBool:0.0];
- [NSNumber numberWithBool:YES];
- [NSNumber numberWithBool:NO];
- [NSNumber numberWithBool:true];
- [NSNumber numberWithBool:false];
- [NSNumber numberWithBool:VAL_INT];
- [NSNumber numberWithBool:VAL_UINT];
-
- [NSNumber numberWithInteger:'a'];
- [NSNumber numberWithInteger:L'a'];
- [NSNumber numberWithInteger:2];
- [NSNumber numberWithInteger:2U];
- [NSNumber numberWithInteger:2u];
- [NSNumber numberWithInteger:2L];
- [NSNumber numberWithInteger:2l];
- [NSNumber numberWithInteger:2LL];
- [NSNumber numberWithInteger:2ll];
- [NSNumber numberWithInteger:2ul];
- [NSNumber numberWithInteger:2lu];
- [NSNumber numberWithInteger:2ull];
- [NSNumber numberWithInteger:2llu];
- [NSNumber numberWithInteger:2.0];
- [NSNumber numberWithInteger:2.0f];
- [NSNumber numberWithInteger:2.0F];
- [NSNumber numberWithInteger:2.0l];
- [NSNumber numberWithInteger:2.0L];
- [NSNumber numberWithInteger:0x2f];
- [NSNumber numberWithInteger:04];
- [NSNumber numberWithInteger:0];
- [NSNumber numberWithInteger:0.0];
- [NSNumber numberWithInteger:YES];
- [NSNumber numberWithInteger:NO];
- [NSNumber numberWithInteger:true];
- [NSNumber numberWithInteger:false];
- [NSNumber numberWithInteger:VAL_INT];
- [NSNumber numberWithInteger:VAL_UINT];
-
- [NSNumber numberWithUnsignedInteger:'a'];
- [NSNumber numberWithUnsignedInteger:L'a'];
- [NSNumber numberWithUnsignedInteger:2];
- [NSNumber numberWithUnsignedInteger:2U];
- [NSNumber numberWithUnsignedInteger:2u];
- [NSNumber numberWithUnsignedInteger:2L];
- [NSNumber numberWithUnsignedInteger:2l];
- [NSNumber numberWithUnsignedInteger:2LL];
- [NSNumber numberWithUnsignedInteger:2ll];
- [NSNumber numberWithUnsignedInteger:2ul];
- [NSNumber numberWithUnsignedInteger:2lu];
- [NSNumber numberWithUnsignedInteger:2ull];
- [NSNumber numberWithUnsignedInteger:2llu];
- [NSNumber numberWithUnsignedInteger:2.0];
- [NSNumber numberWithUnsignedInteger:2.0f];
- [NSNumber numberWithUnsignedInteger:2.0F];
- [NSNumber numberWithUnsignedInteger:2.0l];
- [NSNumber numberWithUnsignedInteger:2.0L];
- [NSNumber numberWithUnsignedInteger:0x2f];
- [NSNumber numberWithUnsignedInteger:04];
- [NSNumber numberWithUnsignedInteger:0];
- [NSNumber numberWithUnsignedInteger:0.0];
- [NSNumber numberWithUnsignedInteger:YES];
- [NSNumber numberWithUnsignedInteger:NO];
- [NSNumber numberWithUnsignedInteger:true];
- [NSNumber numberWithUnsignedInteger:false];
- [NSNumber numberWithUnsignedInteger:VAL_INT];
- [NSNumber numberWithUnsignedInteger:VAL_UINT];
-}
diff --git a/clang/test/ARCMT/objcmt-numeric-literals.m.result b/clang/test/ARCMT/objcmt-numeric-literals.m.result
deleted file mode 100644
index bb7b515566d094..00000000000000
--- a/clang/test/ARCMT/objcmt-numeric-literals.m.result
+++ /dev/null
@@ -1,502 +0,0 @@
-// RUN: rm -rf %t
-// RUN: %clang_cc1 -objcmt-migrate-literals -objcmt-migrate-subscripting -mt-migrate-directory %t %s -x objective-c++
-// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c++ %s.result
-
-#define YES __objc_yes
-#define NO __objc_no
-
-typedef long NSInteger;
-typedef unsigned long NSUInteger;
-typedef signed char BOOL;
-#define nil ((void*) 0)
-
- at interface NSObject
-+ (id)alloc;
- at end
-
- at interface NSNumber : NSObject
- at end
-
- at interface NSNumber (NSNumberCreation)
-- (id)initWithChar:(char)value;
-- (id)initWithUnsignedChar:(unsigned char)value;
-- (id)initWithShort:(short)value;
-- (id)initWithUnsignedShort:(unsigned short)value;
-- (id)initWithInt:(int)value;
-- (id)initWithUnsignedInt:(unsigned int)value;
-- (id)initWithLong:(long)value;
-- (id)initWithUnsignedLong:(unsigned long)value;
-- (id)initWithLongLong:(long long)value;
-- (id)initWithUnsignedLongLong:(unsigned long long)value;
-- (id)initWithFloat:(float)value;
-- (id)initWithDouble:(double)value;
-- (id)initWithBool:(BOOL)value;
-- (id)initWithInteger:(NSInteger)value;
-- (id)initWithUnsignedInteger:(NSUInteger)value;
-
-+ (NSNumber *)numberWithChar:(char)value;
-+ (NSNumber *)numberWithUnsignedChar:(unsigned char)value;
-+ (NSNumber *)numberWithShort:(short)value;
-+ (NSNumber *)numberWithUnsignedShort:(unsigned short)value;
-+ (NSNumber *)numberWithInt:(int)value;
-+ (NSNumber *)numberWithUnsignedInt:(unsigned int)value;
-+ (NSNumber *)numberWithLong:(long)value;
-+ (NSNumber *)numberWithUnsignedLong:(unsigned long)value;
-+ (NSNumber *)numberWithLongLong:(long long)value;
-+ (NSNumber *)numberWithUnsignedLongLong:(unsigned long long)value;
-+ (NSNumber *)numberWithFloat:(float)value;
-+ (NSNumber *)numberWithDouble:(double)value;
-+ (NSNumber *)numberWithBool:(BOOL)value;
-+ (NSNumber *)numberWithInteger:(NSInteger)value;
-+ (NSNumber *)numberWithUnsignedInteger:(NSUInteger)value;
- at end
-
-#define VAL_INT 2
-#define VAL_UINT 2U
-#define VAL_CHAR 'a'
-
-void foo() {
- @'a';
- [NSNumber numberWithChar:L'a'];
- [NSNumber numberWithChar:2];
- [NSNumber numberWithChar:2U];
- [NSNumber numberWithChar:2u];
- [NSNumber numberWithChar:2L];
- [NSNumber numberWithChar:2l];
- [NSNumber numberWithChar:2LL];
- [NSNumber numberWithChar:2ll];
- [NSNumber numberWithChar:2ul];
- [NSNumber numberWithChar:2lu];
- [NSNumber numberWithChar:2ull];
- [NSNumber numberWithChar:2llu];
- [NSNumber numberWithChar:2.0];
- [NSNumber numberWithChar:2.0f];
- [NSNumber numberWithChar:2.0F];
- [NSNumber numberWithChar:2.0l];
- [NSNumber numberWithChar:2.0L];
- [NSNumber numberWithChar:0x2f];
- [NSNumber numberWithChar:04];
- [NSNumber numberWithChar:0];
- [NSNumber numberWithChar:0.0];
- [NSNumber numberWithChar:YES];
- [NSNumber numberWithChar:NO];
- [NSNumber numberWithChar:true];
- [NSNumber numberWithChar:false];
- [NSNumber numberWithChar:VAL_INT];
- [NSNumber numberWithChar:VAL_UINT];
- @VAL_CHAR;
-
- [NSNumber numberWithUnsignedChar:'a'];
- [NSNumber numberWithUnsignedChar:L'a'];
- [NSNumber numberWithUnsignedChar:2];
- [NSNumber numberWithUnsignedChar:2U];
- [NSNumber numberWithUnsignedChar:2u];
- [NSNumber numberWithUnsignedChar:2L];
- [NSNumber numberWithUnsignedChar:2l];
- [NSNumber numberWithUnsignedChar:2LL];
- [NSNumber numberWithUnsignedChar:2ll];
- [NSNumber numberWithUnsignedChar:2ul];
- [NSNumber numberWithUnsignedChar:2lu];
- [NSNumber numberWithUnsignedChar:2ull];
- [NSNumber numberWithUnsignedChar:2llu];
- [NSNumber numberWithUnsignedChar:2.0];
- [NSNumber numberWithUnsignedChar:2.0f];
- [NSNumber numberWithUnsignedChar:2.0F];
- [NSNumber numberWithUnsignedChar:2.0l];
- [NSNumber numberWithUnsignedChar:2.0L];
- [NSNumber numberWithUnsignedChar:0x2f];
- [NSNumber numberWithUnsignedChar:04];
- [NSNumber numberWithUnsignedChar:0];
- [NSNumber numberWithUnsignedChar:0.0];
- [NSNumber numberWithUnsignedChar:YES];
- [NSNumber numberWithUnsignedChar:NO];
- [NSNumber numberWithUnsignedChar:true];
- [NSNumber numberWithUnsignedChar:false];
- [NSNumber numberWithUnsignedChar:VAL_INT];
- [NSNumber numberWithUnsignedChar:VAL_UINT];
- [NSNumber numberWithUnsignedChar:VAL_CHAR];
-
- [NSNumber numberWithShort:'a'];
- [NSNumber numberWithShort:L'a'];
- [NSNumber numberWithShort:2];
- [NSNumber numberWithShort:2U];
- [NSNumber numberWithShort:2u];
- [NSNumber numberWithShort:2L];
- [NSNumber numberWithShort:2l];
- [NSNumber numberWithShort:2LL];
- [NSNumber numberWithShort:2ll];
- [NSNumber numberWithShort:2ul];
- [NSNumber numberWithShort:2lu];
- [NSNumber numberWithShort:2ull];
- [NSNumber numberWithShort:2llu];
- [NSNumber numberWithShort:2.0];
- [NSNumber numberWithShort:2.0f];
- [NSNumber numberWithShort:2.0F];
- [NSNumber numberWithShort:2.0l];
- [NSNumber numberWithShort:2.0L];
- [NSNumber numberWithShort:0x2f];
- [NSNumber numberWithShort:04];
- [NSNumber numberWithShort:0];
- [NSNumber numberWithShort:0.0];
- [NSNumber numberWithShort:YES];
- [NSNumber numberWithShort:NO];
- [NSNumber numberWithShort:true];
- [NSNumber numberWithShort:false];
- [NSNumber numberWithShort:VAL_INT];
- [NSNumber numberWithShort:VAL_UINT];
-
- [NSNumber numberWithUnsignedShort:'a'];
- [NSNumber numberWithUnsignedShort:L'a'];
- [NSNumber numberWithUnsignedShort:2];
- [NSNumber numberWithUnsignedShort:2U];
- [NSNumber numberWithUnsignedShort:2u];
- [NSNumber numberWithUnsignedShort:2L];
- [NSNumber numberWithUnsignedShort:2l];
- [NSNumber numberWithUnsignedShort:2LL];
- [NSNumber numberWithUnsignedShort:2ll];
- [NSNumber numberWithUnsignedShort:2ul];
- [NSNumber numberWithUnsignedShort:2lu];
- [NSNumber numberWithUnsignedShort:2ull];
- [NSNumber numberWithUnsignedShort:2llu];
- [NSNumber numberWithUnsignedShort:2.0];
- [NSNumber numberWithUnsignedShort:2.0f];
- [NSNumber numberWithUnsignedShort:2.0F];
- [NSNumber numberWithUnsignedShort:2.0l];
- [NSNumber numberWithUnsignedShort:2.0L];
- [NSNumber numberWithUnsignedShort:0x2f];
- [NSNumber numberWithUnsignedShort:04];
- [NSNumber numberWithUnsignedShort:0];
- [NSNumber numberWithUnsignedShort:0.0];
- [NSNumber numberWithUnsignedShort:YES];
- [NSNumber numberWithUnsignedShort:NO];
- [NSNumber numberWithUnsignedShort:true];
- [NSNumber numberWithUnsignedShort:false];
- [NSNumber numberWithUnsignedShort:VAL_INT];
- [NSNumber numberWithUnsignedShort:VAL_UINT];
-
- [NSNumber numberWithInt:'a'];
- [NSNumber numberWithInt:L'a'];
- @2;
- @2;
- @2;
- @2;
- @2;
- @2;
- @2;
- @2;
- @2;
- @2;
- @2;
- [NSNumber numberWithInt:2.0];
- [NSNumber numberWithInt:2.0f];
- [NSNumber numberWithInt:2.0F];
- [NSNumber numberWithInt:2.0l];
- [NSNumber numberWithInt:2.0L];
- @0x2f;
- @04;
- @0;
- [NSNumber numberWithInt:0.0];
- [NSNumber numberWithInt:YES];
- [NSNumber numberWithInt:NO];
- [NSNumber numberWithInt:true];
- [NSNumber numberWithInt:false];
- @VAL_INT;
- [NSNumber numberWithInt:VAL_UINT];
-
- (void)[[NSNumber alloc] initWithInt:2];
- (void)[[NSNumber alloc] initWithInt:2U];
-
- @+2;
- @-2;
-
- [NSNumber numberWithUnsignedInt:'a'];
- [NSNumber numberWithUnsignedInt:L'a'];
- @2U;
- @2U;
- @2u;
- @2U;
- @2u;
- @2U;
- @2u;
- @2u;
- @2u;
- @2u;
- @2u;
- [NSNumber numberWithUnsignedInt:2.0];
- [NSNumber numberWithUnsignedInt:2.0f];
- [NSNumber numberWithUnsignedInt:2.0F];
- [NSNumber numberWithUnsignedInt:2.0l];
- [NSNumber numberWithUnsignedInt:2.0L];
- @0x2fU;
- @04U;
- @0U;
- [NSNumber numberWithUnsignedInt:0.0];
- [NSNumber numberWithUnsignedInt:YES];
- [NSNumber numberWithUnsignedInt:NO];
- [NSNumber numberWithUnsignedInt:true];
- [NSNumber numberWithUnsignedInt:false];
- [NSNumber numberWithUnsignedInt:VAL_INT];
- @VAL_UINT;
-
- [NSNumber numberWithLong:'a'];
- [NSNumber numberWithLong:L'a'];
- @2L;
- @2L;
- @2l;
- @2L;
- @2l;
- @2L;
- @2l;
- @2l;
- @2l;
- @2l;
- @2l;
- [NSNumber numberWithLong:2.0];
- [NSNumber numberWithLong:2.0f];
- [NSNumber numberWithLong:2.0F];
- [NSNumber numberWithLong:2.0l];
- [NSNumber numberWithLong:2.0L];
- @0x2fL;
- @04L;
- @0L;
- [NSNumber numberWithLong:0.0];
- [NSNumber numberWithLong:YES];
- [NSNumber numberWithLong:NO];
- [NSNumber numberWithLong:true];
- [NSNumber numberWithLong:false];
- [NSNumber numberWithLong:VAL_INT];
- [NSNumber numberWithLong:VAL_UINT];
-
- [NSNumber numberWithUnsignedLong:'a'];
- [NSNumber numberWithUnsignedLong:L'a'];
- @2UL;
- @2UL;
- @2ul;
- @2UL;
- @2ul;
- @2UL;
- @2ul;
- @2ul;
- @2lu;
- @2ul;
- @2ul;
- [NSNumber numberWithUnsignedLong:2.0];
- [NSNumber numberWithUnsignedLong:2.0f];
- [NSNumber numberWithUnsignedLong:2.0F];
- [NSNumber numberWithUnsignedLong:2.0l];
- [NSNumber numberWithUnsignedLong:2.0L];
- @0x2fUL;
- @04UL;
- @0UL;
- [NSNumber numberWithUnsignedLong:0.0];
- [NSNumber numberWithUnsignedLong:YES];
- [NSNumber numberWithUnsignedLong:NO];
- [NSNumber numberWithUnsignedLong:true];
- [NSNumber numberWithUnsignedLong:false];
- [NSNumber numberWithUnsignedLong:VAL_INT];
- [NSNumber numberWithUnsignedLong:VAL_UINT];
-
- [NSNumber numberWithLongLong:'a'];
- [NSNumber numberWithLongLong:L'a'];
- @2LL;
- @2LL;
- @2ll;
- @2LL;
- @2ll;
- @2LL;
- @2ll;
- @2ll;
- @2ll;
- @2ll;
- @2ll;
- [NSNumber numberWithLongLong:2.0];
- [NSNumber numberWithLongLong:2.0f];
- [NSNumber numberWithLongLong:2.0F];
- [NSNumber numberWithLongLong:2.0l];
- [NSNumber numberWithLongLong:2.0L];
- @0x2fLL;
- @04LL;
- @0LL;
- [NSNumber numberWithLongLong:0.0];
- [NSNumber numberWithLongLong:YES];
- [NSNumber numberWithLongLong:NO];
- [NSNumber numberWithLongLong:true];
- [NSNumber numberWithLongLong:false];
- [NSNumber numberWithLongLong:VAL_INT];
- [NSNumber numberWithLongLong:VAL_UINT];
-
- [NSNumber numberWithUnsignedLongLong:'a'];
- [NSNumber numberWithUnsignedLongLong:L'a'];
- @2ULL;
- @2ULL;
- @2ull;
- @2ULL;
- @2ull;
- @2ULL;
- @2ull;
- @2ull;
- @2ull;
- @2ull;
- @2llu;
- [NSNumber numberWithUnsignedLongLong:2.0];
- [NSNumber numberWithUnsignedLongLong:2.0f];
- [NSNumber numberWithUnsignedLongLong:2.0F];
- [NSNumber numberWithUnsignedLongLong:2.0l];
- [NSNumber numberWithUnsignedLongLong:2.0L];
- @0x2fULL;
- @04ULL;
- @0ULL;
- [NSNumber numberWithUnsignedLongLong:0.0];
- [NSNumber numberWithUnsignedLongLong:YES];
- [NSNumber numberWithUnsignedLongLong:NO];
- [NSNumber numberWithUnsignedLongLong:true];
- [NSNumber numberWithUnsignedLongLong:false];
- [NSNumber numberWithUnsignedLongLong:VAL_INT];
- [NSNumber numberWithUnsignedLongLong:VAL_UINT];
-
- [NSNumber numberWithFloat:'a'];
- [NSNumber numberWithFloat:L'a'];
- @2.0f;
- @2.0f;
- @2.0f;
- @2.0f;
- @2.0f;
- @2.0f;
- @2.0f;
- @2.0f;
- @2.0f;
- @2.0f;
- @2.0f;
- @2.0f;
- @2.0f;
- @2.0F;
- @2.0f;
- @2.0f;
- [NSNumber numberWithFloat:0x2f];
- [NSNumber numberWithFloat:04];
- @0.0f;
- @0.0f;
- [NSNumber numberWithFloat:YES];
- [NSNumber numberWithFloat:NO];
- [NSNumber numberWithFloat:true];
- [NSNumber numberWithFloat:false];
- [NSNumber numberWithFloat:VAL_INT];
- [NSNumber numberWithFloat:VAL_UINT];
-
- [NSNumber numberWithDouble:'a'];
- [NSNumber numberWithDouble:L'a'];
- @2.0;
- @2.0;
- @2.0;
- @2.0;
- @2.0;
- @2.0;
- @2.0;
- @2.0;
- @2.0;
- @2.0;
- @2.0;
- @2.0;
- @2.0;
- @2.0;
- @2.0;
- @2.0;
- [NSNumber numberWithDouble:0x2f];
- [NSNumber numberWithDouble:04];
- @0.0;
- @0.0;
- [NSNumber numberWithDouble:YES];
- [NSNumber numberWithDouble:NO];
- [NSNumber numberWithDouble:true];
- [NSNumber numberWithDouble:false];
- [NSNumber numberWithDouble:VAL_INT];
- [NSNumber numberWithDouble:VAL_UINT];
-
- [NSNumber numberWithBool:'a'];
- [NSNumber numberWithBool:L'a'];
- [NSNumber numberWithBool:2];
- [NSNumber numberWithBool:2U];
- [NSNumber numberWithBool:2u];
- [NSNumber numberWithBool:2L];
- [NSNumber numberWithBool:2l];
- [NSNumber numberWithBool:2LL];
- [NSNumber numberWithBool:2ll];
- [NSNumber numberWithBool:2ul];
- [NSNumber numberWithBool:2lu];
- [NSNumber numberWithBool:2ull];
- [NSNumber numberWithBool:2llu];
- [NSNumber numberWithBool:2.0];
- [NSNumber numberWithBool:2.0f];
- [NSNumber numberWithBool:2.0F];
- [NSNumber numberWithBool:2.0l];
- [NSNumber numberWithBool:2.0L];
- [NSNumber numberWithBool:0x2f];
- [NSNumber numberWithBool:04];
- [NSNumber numberWithBool:0];
- [NSNumber numberWithBool:0.0];
- @YES;
- @NO;
- @true;
- @false;
- [NSNumber numberWithBool:VAL_INT];
- [NSNumber numberWithBool:VAL_UINT];
-
- [NSNumber numberWithInteger:'a'];
- [NSNumber numberWithInteger:L'a'];
- @2;
- @2;
- @2;
- @2L;
- @2l;
- @2;
- @2;
- @2;
- @2;
- @2;
- @2;
- [NSNumber numberWithInteger:2.0];
- [NSNumber numberWithInteger:2.0f];
- [NSNumber numberWithInteger:2.0F];
- [NSNumber numberWithInteger:2.0l];
- [NSNumber numberWithInteger:2.0L];
- @0x2f;
- @04;
- @0;
- [NSNumber numberWithInteger:0.0];
- [NSNumber numberWithInteger:YES];
- [NSNumber numberWithInteger:NO];
- [NSNumber numberWithInteger:true];
- [NSNumber numberWithInteger:false];
- @VAL_INT;
- [NSNumber numberWithInteger:VAL_UINT];
-
- [NSNumber numberWithUnsignedInteger:'a'];
- [NSNumber numberWithUnsignedInteger:L'a'];
- @2U;
- @2U;
- @2u;
- @2U;
- @2u;
- @2U;
- @2u;
- @2ul;
- @2lu;
- @2u;
- @2u;
- [NSNumber numberWithUnsignedInteger:2.0];
- [NSNumber numberWithUnsignedInteger:2.0f];
- [NSNumber numberWithUnsignedInteger:2.0F];
- [NSNumber numberWithUnsignedInteger:2.0l];
- [NSNumber numberWithUnsignedInteger:2.0L];
- @0x2fU;
- @04U;
- @0U;
- [NSNumber numberWithUnsignedInteger:0.0];
- [NSNumber numberWithUnsignedInteger:YES];
- [NSNumber numberWithUnsignedInteger:NO];
- [NSNumber numberWithUnsignedInteger:true];
- [NSNumber numberWithUnsignedInteger:false];
- [NSNumber numberWithUnsignedInteger:VAL_INT];
- @VAL_UINT;
-}
diff --git a/clang/test/ARCMT/objcmt-property-availability.m b/clang/test/ARCMT/objcmt-property-availability.m
deleted file mode 100644
index 37ba74f3346fb4..00000000000000
--- a/clang/test/ARCMT/objcmt-property-availability.m
+++ /dev/null
@@ -1,45 +0,0 @@
-// RUN: rm -rf %t
-// RUN: %clang_cc1 -objcmt-migrate-readwrite-property -objcmt-migrate-readonly-property -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11
-// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c -fobjc-runtime-has-weak -fobjc-arc %s.result
-
-
-#define __NSi_7_0 introduced=7.0
-#define __NSi_6_0 introduced=6.0
-
-#define CF_AVAILABLE(_mac, _ios) __attribute__((availability(ios,__NSi_##_ios)))
-#define CF_AVAILABLE_MAC(_mac) __attribute__((availability(macosx,__NSi_##_mac)))
-#define CF_AVAILABLE_IOS(_ios) __attribute__((availability(macosx,unavailable)))
-
-#define NS_AVAILABLE(_mac, _ios) CF_AVAILABLE(_mac, _ios)
-#define NS_AVAILABLE_MAC(_mac) CF_AVAILABLE_MAC(_mac)
-#define NS_AVAILABLE_IOS(_ios) CF_AVAILABLE_IOS(_ios)
-
-#define UNAVAILABLE __attribute__((unavailable("not available in automatic reference counting mode")))
-
- at interface MKMapItem
-- (MKMapItem *)source NS_AVAILABLE(10_9, 6_0);
-- (void)setSource:(MKMapItem *)source NS_AVAILABLE(10_9, 7_0);
-
-- (void)setDest:(MKMapItem *)source NS_AVAILABLE(10_9, 6_0);
-- (MKMapItem *)dest NS_AVAILABLE(10_9, 6_0);
-
-- (MKMapItem *)final;
-- (void)setFinal:(MKMapItem *)source;
-
-- (MKMapItem *)total NS_AVAILABLE(10_9, 6_0);
-- (void)setTotal:(MKMapItem *)source;
-
-- (MKMapItem *)comp NS_AVAILABLE(10_9, 6_0);
-- (void)setComp:(MKMapItem *)source UNAVAILABLE;
-
-- (MKMapItem *)tally UNAVAILABLE NS_AVAILABLE(10_9, 6_0);
-- (void)setTally:(MKMapItem *)source UNAVAILABLE NS_AVAILABLE(10_9, 6_0);
-
-- (MKMapItem *)itally NS_AVAILABLE(10_9, 6_0);
-- (void)setItally:(MKMapItem *)source UNAVAILABLE NS_AVAILABLE(10_9, 6_0);
-
-- (MKMapItem *)normal UNAVAILABLE;
-- (void)setNormal:(MKMapItem *)source UNAVAILABLE NS_AVAILABLE(10_9, 6_0);
- at end
-
diff --git a/clang/test/ARCMT/objcmt-property-availability.m.result b/clang/test/ARCMT/objcmt-property-availability.m.result
deleted file mode 100644
index 3a212ac894c4a3..00000000000000
--- a/clang/test/ARCMT/objcmt-property-availability.m.result
+++ /dev/null
@@ -1,42 +0,0 @@
-// RUN: rm -rf %t
-// RUN: %clang_cc1 -objcmt-migrate-readwrite-property -objcmt-migrate-readonly-property -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11
-// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c -fobjc-runtime-has-weak -fobjc-arc %s.result
-
-
-#define __NSi_7_0 introduced=7.0
-#define __NSi_6_0 introduced=6.0
-
-#define CF_AVAILABLE(_mac, _ios) __attribute__((availability(ios,__NSi_##_ios)))
-#define CF_AVAILABLE_MAC(_mac) __attribute__((availability(macosx,__NSi_##_mac)))
-#define CF_AVAILABLE_IOS(_ios) __attribute__((availability(macosx,unavailable)))
-
-#define NS_AVAILABLE(_mac, _ios) CF_AVAILABLE(_mac, _ios)
-#define NS_AVAILABLE_MAC(_mac) CF_AVAILABLE_MAC(_mac)
-#define NS_AVAILABLE_IOS(_ios) CF_AVAILABLE_IOS(_ios)
-
-#define UNAVAILABLE __attribute__((unavailable("not available in automatic reference counting mode")))
-
- at interface MKMapItem
- at property (nonatomic, strong) MKMapItem *source NS_AVAILABLE(10_9, 6_0);
-- (void)setSource:(MKMapItem *)source NS_AVAILABLE(10_9, 7_0);
-
- at property (nonatomic, strong) MKMapItem *dest NS_AVAILABLE(10_9, 6_0);
-
- at property (nonatomic, strong) MKMapItem *final;
-
- at property (nonatomic, strong) MKMapItem *total NS_AVAILABLE(10_9, 6_0);
-- (void)setTotal:(MKMapItem *)source;
-
-- (MKMapItem *)comp NS_AVAILABLE(10_9, 6_0);
-- (void)setComp:(MKMapItem *)source UNAVAILABLE;
-
- at property (nonatomic, strong) MKMapItem *tally UNAVAILABLE NS_AVAILABLE(10_9, 6_0);
-
-- (MKMapItem *)itally NS_AVAILABLE(10_9, 6_0);
-- (void)setItally:(MKMapItem *)source UNAVAILABLE NS_AVAILABLE(10_9, 6_0);
-
-- (MKMapItem *)normal UNAVAILABLE;
-- (void)setNormal:(MKMapItem *)source UNAVAILABLE NS_AVAILABLE(10_9, 6_0);
- at end
-
diff --git a/clang/test/ARCMT/objcmt-property-dot-syntax.m b/clang/test/ARCMT/objcmt-property-dot-syntax.m
deleted file mode 100644
index ec75b5140e18df..00000000000000
--- a/clang/test/ARCMT/objcmt-property-dot-syntax.m
+++ /dev/null
@@ -1,117 +0,0 @@
-// RUN: rm -rf %t
-// RUN: %clang_cc1 -objcmt-migrate-property-dot-syntax -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11
-// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result
-// RUN: %clang_cc1 -fblocks -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c -fobjc-runtime-has-weak -fobjc-arc %s.result
-
- at class NSString;
-
- at protocol NSObject
- at property (readonly, copy) NSString *description;
- at end
-
- at interface NSObject <NSObject> @end
-
- at interface P : NSObject
-{
- P* obj;
- int i1, i2, i3;
-}
- at property int count;
- at property (copy) P* PropertyReturnsPObj;
-- (P*) MethodReturnsPObj;
- at end
-
-P* fun(void);
-
- at implementation P
-- (int) Meth : (P*)array {
- [obj setCount : 100];
-
- [(P*)0 setCount : [array count]];
-
- [[obj PropertyReturnsPObj] setCount : [array count]];
-
- [obj setCount : (i1+i2*i3 - 100)];
-
- return [obj count] -
- [(P*)0 count] + [array count] +
- [fun() count] -
- [[obj PropertyReturnsPObj] count] +
- [self->obj count];
-}
-
-- (P*) MethodReturnsPObj { return 0; }
-
-- (NSString *)description { return [super description]; }
- at end
-
- at interface Sub : P
- at end
-
- at implementation Sub
-- (int) Meth : (P*)array {
- [super setCount : 100];
-
- [super setCount : [array count]];
-
- [[super PropertyReturnsPObj] setCount : [array count]];
-
- [super setCount : (i1+i2*i3 - 100)];
-
- return [super count] -
- [(P*)0 count] + [array count] +
- [fun() count] -
- [[super PropertyReturnsPObj] count] +
- [self->obj count];
-}
- at end
-
-
- at interface Rdar19038838
- at property id newItem; // should be marked objc_method_family(none), but isn't.
- at end
-
-id testRdar19038838(Rdar19038838 *obj) {
- return [obj newItem];
-}
-
- at interface rdar19381786 : NSObject
-{
- rdar19381786* obj;
-}
- at property int count;
- at end
-
- at protocol PR
- at property int count;
- at end
-
- at implementation rdar19381786
--(void)test:(id)some : (id<PR>)qsome : (SEL)selsome
-{
- [obj setCount : 100];
- [some setCount : [some count]];
- [qsome setCount : [qsome count]];
-}
- at end
-
-int NSOnState;
-int ArrNSOnState[4];
- at interface rdar19140114 : NSObject
-{
- rdar19140114* menuItem;
-}
- at property int state;
- at end
-
- at implementation rdar19140114
-- (void) Meth {
- [menuItem setState:NSOnState];
- [menuItem setState :NSOnState];
- [menuItem setState :ArrNSOnState[NSOnState]];
- [menuItem setState : NSOnState];
- [menuItem setState: NSOnState];
- [menuItem setState: NSOnState];
- [menuItem setState : NSOnState];
-}
- at end
diff --git a/clang/test/ARCMT/objcmt-property-dot-syntax.m.result b/clang/test/ARCMT/objcmt-property-dot-syntax.m.result
deleted file mode 100644
index 5153b0e658f6ac..00000000000000
--- a/clang/test/ARCMT/objcmt-property-dot-syntax.m.result
+++ /dev/null
@@ -1,117 +0,0 @@
-// RUN: rm -rf %t
-// RUN: %clang_cc1 -objcmt-migrate-property-dot-syntax -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11
-// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result
-// RUN: %clang_cc1 -fblocks -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c -fobjc-runtime-has-weak -fobjc-arc %s.result
-
- at class NSString;
-
- at protocol NSObject
- at property (readonly, copy) NSString *description;
- at end
-
- at interface NSObject <NSObject> @end
-
- at interface P : NSObject
-{
- P* obj;
- int i1, i2, i3;
-}
- at property int count;
- at property (copy) P* PropertyReturnsPObj;
-- (P*) MethodReturnsPObj;
- at end
-
-P* fun(void);
-
- at implementation P
-- (int) Meth : (P*)array {
- obj.count = 100;
-
- ((P*)0).count = array.count;
-
- obj.PropertyReturnsPObj.count = array.count;
-
- obj.count = (i1+i2*i3 - 100);
-
- return obj.count -
- ((P*)0).count + array.count +
- fun().count -
- obj.PropertyReturnsPObj.count +
- self->obj.count;
-}
-
-- (P*) MethodReturnsPObj { return 0; }
-
-- (NSString *)description { return super.description; }
- at end
-
- at interface Sub : P
- at end
-
- at implementation Sub
-- (int) Meth : (P*)array {
- super.count = 100;
-
- super.count = array.count;
-
- super.PropertyReturnsPObj.count = array.count;
-
- super.count = (i1+i2*i3 - 100);
-
- return super.count -
- ((P*)0).count + array.count +
- fun().count -
- super.PropertyReturnsPObj.count +
- self->obj.count;
-}
- at end
-
-
- at interface Rdar19038838
- at property id newItem; // should be marked objc_method_family(none), but isn't.
- at end
-
-id testRdar19038838(Rdar19038838 *obj) {
- return obj.newItem;
-}
-
- at interface rdar19381786 : NSObject
-{
- rdar19381786* obj;
-}
- at property int count;
- at end
-
- at protocol PR
- at property int count;
- at end
-
- at implementation rdar19381786
--(void)test:(id)some : (id<PR>)qsome : (SEL)selsome
-{
- obj.count = 100;
- [some setCount : [some count]];
- qsome.count = qsome.count;
-}
- at end
-
-int NSOnState;
-int ArrNSOnState[4];
- at interface rdar19140114 : NSObject
-{
- rdar19140114* menuItem;
-}
- at property int state;
- at end
-
- at implementation rdar19140114
-- (void) Meth {
- menuItem.state = NSOnState;
- menuItem.state = NSOnState;
- menuItem.state = ArrNSOnState[NSOnState];
- menuItem.state = NSOnState;
- menuItem.state = NSOnState;
- menuItem.state = NSOnState;
- menuItem.state = NSOnState;
-}
- at end
diff --git a/clang/test/ARCMT/objcmt-property.m b/clang/test/ARCMT/objcmt-property.m
deleted file mode 100644
index f2b722e66d9699..00000000000000
--- a/clang/test/ARCMT/objcmt-property.m
+++ /dev/null
@@ -1,243 +0,0 @@
-// RUN: rm -rf %t
-// RUN: %clang_cc1 -fblocks -objcmt-migrate-readwrite-property -objcmt-migrate-readonly-property -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11
-// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result
-// RUN: %clang_cc1 -fblocks -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c -fobjc-runtime-has-weak -fobjc-arc %s.result
-
-#define WEBKIT_OBJC_METHOD_ANNOTATION(ANNOTATION) ANNOTATION
-#define WEAK_IMPORT_ATTRIBUTE __attribute__((objc_arc_weak_reference_unavailable))
-#define AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER
-#define DEPRECATED __attribute__((deprecated))
-
-typedef char BOOL;
- at class NSString;
- at protocol NSCopying @end
-
- at interface NSObject <NSCopying>
- at end
-
- at interface NSDictionary : NSObject
- at end
-
- at interface I : NSObject {
- int ivarVal;
-}
-- (void) setWeakProp : (NSString *__weak)Val;
-- (NSString *__weak) WeakProp;
-
-- (NSString *) StrongProp;
-- (void) setStrongProp : (NSString *)Val;
-
-- (NSString *) UnavailProp __attribute__((unavailable));
-- (void) setUnavailProp : (NSString *)Val;
-
-- (NSString *) UnavailProp1 __attribute__((unavailable));
-- (void) setUnavailProp1 : (NSString *)Val __attribute__((unavailable));
-
-- (NSString *) UnavailProp2;
-- (void) setUnavailProp2 : (NSString *)Val __attribute__((unavailable));
-
-- (NSDictionary*) undoAction;
-- (void) setUndoAction: (NSDictionary*)Arg;
- at end
-
- at implementation I
- at end
-
- at class NSArray;
-
- at interface MyClass2 {
- at private
- NSArray *_names1;
- NSArray *_names2;
- NSArray *_names3;
- NSArray *_names4;
-}
-- (void)setNames1:(NSArray *)names;
-- (void)setNames4:(__strong NSArray *)names;
-- (void)setNames3:(__strong NSArray *)names;
-- (void)setNames2:(NSArray *)names;
-- (NSArray *) names2;
-- (NSArray *)names3;
-- (__strong NSArray *)names4;
-- (NSArray *) names1;
- at end
-
-// Properties that contain the name "delegate" or "dataSource",
-// or have exact name "target" have unsafe_unretained attribute.
- at interface NSInvocation
-- (id)target;
-- (void)setTarget:(id)target;
-
-- (id) dataSource;
-
-- (id)delegate;
-
-- (id)xxxdelegateYYY;
-- (void)setXxxdelegateYYY:(id)delegate;
-
-- (void)setDataSource:(id)source;
-
-- (id)MYtarget;
-- (void)setMYtarget: (id)target;
-
-- (id)targetX;
-- (void)setTargetX: (id)t;
-
-- (int)value;
-- (void)setValue: (int)val;
-
--(BOOL) isContinuous;
--(void) setContinuous:(BOOL)value;
-
-- (id) isAnObject;
-- (void)setAnObject : (id) object;
-
-- (BOOL) isinValid;
-- (void) setInValid : (BOOL) arg;
-
-- (void) Nothing;
-- (int) Length;
-- (id) object;
-+ (double) D;
-- (void *)JSObject WEBKIT_OBJC_METHOD_ANNOTATION(AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER);
-- (BOOL)isIgnoringInteractionEvents;
-
-- (NSString *)getStringValue;
-- (BOOL)getCounterValue;
-- (void)setStringValue:(NSString *)stringValue AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER;
-- (NSDictionary *)getns_dixtionary;
-
-- (BOOL)is3bar; // watch out
-- (NSString *)get3foo; // watch out
-
-- (BOOL) getM;
-- (BOOL) getMA;
-- (BOOL) getALL;
-- (BOOL) getMANY;
-- (BOOL) getSome;
- at end
-
-
- at interface NSInvocation(CAT)
-- (id)target;
-- (void)setTarget:(id)target;
-
-- (id) dataSource;
-
-- (id)xxxdelegateYYY;
-- (void)setXxxdelegateYYY:(id)delegate;
-
-- (void)setDataSource:(id)source;
-
-- (id)MYtarget;
-- (void)setMYtarget: (id)target;
-
-- (id)targetX;
-- (void)setTargetX: (id)t;
-
-- (int)value;
-- (void)setValue: (int)val;
-
--(BOOL) isContinuous;
--(void) setContinuous:(BOOL)value;
-
-- (id) isAnObject;
-- (void)setAnObject : (id) object;
-
-- (BOOL) isinValid;
-- (void) setInValid : (BOOL) arg;
-
-- (void) Nothing;
-- (int) Length;
-- (id) object;
-+ (double) D;
-
-- (BOOL)is3bar; // watch out
-- (NSString *)get3foo; // watch out
-
-- (BOOL) getM;
-- (BOOL) getMA;
-- (BOOL) getALL;
-- (BOOL) getMANY;
-- (BOOL) getSome;
- at end
-
-DEPRECATED
- at interface I_DEP
-- (BOOL) isinValid;
-- (void) setInValid : (BOOL) arg;
- at end
-
- at interface AnotherOne
-- (BOOL) isinValid DEPRECATED;
-- (void) setInValid : (BOOL) arg;
-- (id)MYtarget;
-- (void)setMYtarget: (id)target DEPRECATED;
-- (BOOL) getM DEPRECATED;
-
-- (id)xxxdelegateYYY DEPRECATED;
-- (void)setXxxdelegateYYY:(id)delegate DEPRECATED;
- at end
-
-#define NS_AVAILABLE __attribute__((availability(macosx,introduced=10.0)))
-#define NORETURN __attribute__((noreturn))
-#define ALIGNED __attribute__((aligned(16)))
-
- at interface NSURL
-// Do not infer a property.
-- (NSURL *)appStoreReceiptURL NS_AVAILABLE;
-- (void) setAppStoreReceiptURL : (NSURL *)object;
-
-- (NSURL *)appStoreReceiptURLX NS_AVAILABLE;
-- (void) setAppStoreReceiptURLX : (NSURL *)object NS_AVAILABLE;
-
-// Do not infer a property.
-- (NSURL *)appStoreReceiptURLY ;
-- (void) setAppStoreReceiptURLY : (NSURL *)object NS_AVAILABLE;
-
-- (id)OkToInfer NS_AVAILABLE;
-
-// Do not infer a property.
-- (NSURL *)appStoreReceiptURLZ ;
-- (void) setAppStoreReceiptURLZ : (NSURL *)object NS_AVAILABLE;
-
-// Do not infer a property.
-- (id) t1 NORETURN NS_AVAILABLE;
-- (void) setT1 : (id) arg NS_AVAILABLE;
-
-- (id)method1 ALIGNED NS_AVAILABLE;
-- (void) setMethod1 : (id) object NS_AVAILABLE ALIGNED;
-
-- (NSURL *)init; // No Change
-+ (id)alloc; // No Change
-
-- (BOOL)is1stClass; // Not a valid property
-- (BOOL)isClass; // This is a valid property 'class' is not a keyword in ObjC
-- (BOOL)isDouble; // Not a valid property
-
- at end
-
- at class NSMutableDictionary;
-
- at interface NSArray
-- (id (^)(id, NSArray *, NSMutableDictionary *)) expressionBlock;
-- (id (^)(id, NSArray *, NSMutableDictionary *)) MyBlock;
-- (void) setMyBlock : (id (^)(id, NSArray *, NSMutableDictionary *)) bl;
-- (id (*)(id, NSArray *, NSMutableDictionary *)) expressionFuncptr;
-- (id (*)(id, NSArray *, NSMutableDictionary *)) MyFuncptr;
-- (void) setMyFuncptr : (id (*)(id, NSArray *, NSMutableDictionary *)) bl;
- at end
-
- at interface rdar15231241
- at property (nonatomic, readonly) double Ddelegate;
- at property (nonatomic, readonly) float Fdelegate;
- at property (nonatomic, readonly) int Idelegate;
- at property (nonatomic, readonly) BOOL Bdelegate;
- at end
-
- at protocol NSObject @end
- at protocol MyProtocol <NSObject>
-- (id)readonlyProperty;
-- (id)readWriteProperty;
-- (void)setReadWriteProperty:(id)readWriteProperty;
- at end
diff --git a/clang/test/ARCMT/objcmt-property.m.result b/clang/test/ARCMT/objcmt-property.m.result
deleted file mode 100644
index 610f027cee5c15..00000000000000
--- a/clang/test/ARCMT/objcmt-property.m.result
+++ /dev/null
@@ -1,215 +0,0 @@
-// RUN: rm -rf %t
-// RUN: %clang_cc1 -fblocks -objcmt-migrate-readwrite-property -objcmt-migrate-readonly-property -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11
-// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result
-// RUN: %clang_cc1 -fblocks -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c -fobjc-runtime-has-weak -fobjc-arc %s.result
-
-#define WEBKIT_OBJC_METHOD_ANNOTATION(ANNOTATION) ANNOTATION
-#define WEAK_IMPORT_ATTRIBUTE __attribute__((objc_arc_weak_reference_unavailable))
-#define AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER
-#define DEPRECATED __attribute__((deprecated))
-
-typedef char BOOL;
- at class NSString;
- at protocol NSCopying @end
-
- at interface NSObject <NSCopying>
- at end
-
- at interface NSDictionary : NSObject
- at end
-
- at interface I : NSObject {
- int ivarVal;
-}
- at property (nonatomic, weak) NSString *WeakProp;
-
- at property (nonatomic, strong) NSString *StrongProp;
-
- at property (nonatomic, strong) NSString *UnavailProp __attribute__((unavailable));
-- (void) setUnavailProp : (NSString *)Val;
-
- at property (nonatomic, strong) NSString *UnavailProp1 __attribute__((unavailable));
-
- at property (nonatomic, strong) NSString *UnavailProp2;
-- (void) setUnavailProp2 : (NSString *)Val __attribute__((unavailable));
-
- at property (nonatomic, copy) NSDictionary *undoAction;
- at end
-
- at implementation I
- at end
-
- at class NSArray;
-
- at interface MyClass2 {
- at private
- NSArray *_names1;
- NSArray *_names2;
- NSArray *_names3;
- NSArray *_names4;
-}
- at property (nonatomic, strong) NSArray *names2;
- at property (nonatomic, strong) NSArray *names3;
- at property (nonatomic, strong) NSArray *names4;
- at property (nonatomic, strong) NSArray *names1;
- at end
-
-// Properties that contain the name "delegate" or "dataSource",
-// or have exact name "target" have unsafe_unretained attribute.
- at interface NSInvocation
- at property (nonatomic, assign) id target;
-
- at property (nonatomic, assign) id dataSource;
-
- at property (nonatomic, readonly, assign) id delegate;
-
- at property (nonatomic, assign) id xxxdelegateYYY;
-
-
- at property (nonatomic, strong) id MYtarget;
-
- at property (nonatomic, strong) id targetX;
-
- at property (nonatomic) int value;
-
- at property (nonatomic, getter=isContinuous) BOOL continuous;
-
-- (id) isAnObject;
-- (void)setAnObject : (id) object;
-
- at property (nonatomic, getter=isinValid, readonly) BOOL inValid;
-- (void) setInValid : (BOOL) arg;
-
-- (void) Nothing;
- at property (nonatomic, readonly) int Length;
- at property (nonatomic, readonly, strong) id object;
-+ (double) D;
- at property (nonatomic, readonly) void *JSObject WEBKIT_OBJC_METHOD_ANNOTATION(AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER);
- at property (nonatomic, getter=isIgnoringInteractionEvents, readonly) BOOL ignoringInteractionEvents;
-
- at property (nonatomic, getter=getStringValue, strong) NSString *stringValue;
- at property (nonatomic, getter=getCounterValue, readonly) BOOL counterValue;
- at property (nonatomic, getter=getns_dixtionary, readonly, copy) NSDictionary *ns_dixtionary;
-
-- (BOOL)is3bar; // watch out
-- (NSString *)get3foo; // watch out
-
- at property (nonatomic, getter=getM, readonly) BOOL m;
- at property (nonatomic, getter=getMA, readonly) BOOL MA;
- at property (nonatomic, getter=getALL, readonly) BOOL ALL;
- at property (nonatomic, getter=getMANY, readonly) BOOL MANY;
- at property (nonatomic, getter=getSome, readonly) BOOL some;
- at end
-
-
- at interface NSInvocation(CAT)
- at property (nonatomic, assign) id target;
-
- at property (nonatomic, assign) id dataSource;
-
- at property (nonatomic, assign) id xxxdelegateYYY;
-
-
- at property (nonatomic, strong) id MYtarget;
-
- at property (nonatomic, strong) id targetX;
-
- at property (nonatomic) int value;
-
- at property (nonatomic, getter=isContinuous) BOOL continuous;
-
-- (id) isAnObject;
-- (void)setAnObject : (id) object;
-
- at property (nonatomic, getter=isinValid, readonly) BOOL inValid;
-- (void) setInValid : (BOOL) arg;
-
-- (void) Nothing;
- at property (nonatomic, readonly) int Length;
- at property (nonatomic, readonly, strong) id object;
-+ (double) D;
-
-- (BOOL)is3bar; // watch out
-- (NSString *)get3foo; // watch out
-
- at property (nonatomic, getter=getM, readonly) BOOL m;
- at property (nonatomic, getter=getMA, readonly) BOOL MA;
- at property (nonatomic, getter=getALL, readonly) BOOL ALL;
- at property (nonatomic, getter=getMANY, readonly) BOOL MANY;
- at property (nonatomic, getter=getSome, readonly) BOOL some;
- at end
-
-DEPRECATED
- at interface I_DEP
-- (BOOL) isinValid;
-- (void) setInValid : (BOOL) arg;
- at end
-
- at interface AnotherOne
-- (BOOL) isinValid DEPRECATED;
-- (void) setInValid : (BOOL) arg;
-- (id)MYtarget;
-- (void)setMYtarget: (id)target DEPRECATED;
-- (BOOL) getM DEPRECATED;
-
-- (id)xxxdelegateYYY DEPRECATED;
-- (void)setXxxdelegateYYY:(id)delegate DEPRECATED;
- at end
-
-#define NS_AVAILABLE __attribute__((availability(macosx,introduced=10.0)))
-#define NORETURN __attribute__((noreturn))
-#define ALIGNED __attribute__((aligned(16)))
-
- at interface NSURL
-// Do not infer a property.
- at property (nonatomic, strong) NSURL *appStoreReceiptURL NS_AVAILABLE;
-- (void) setAppStoreReceiptURL : (NSURL *)object;
-
- at property (nonatomic, strong) NSURL *appStoreReceiptURLX NS_AVAILABLE;
-
-// Do not infer a property.
- at property (nonatomic, strong) NSURL *appStoreReceiptURLY ;
-- (void) setAppStoreReceiptURLY : (NSURL *)object NS_AVAILABLE;
-
- at property (nonatomic, readonly, strong) id OkToInfer NS_AVAILABLE;
-
-// Do not infer a property.
- at property (nonatomic, strong) NSURL *appStoreReceiptURLZ ;
-- (void) setAppStoreReceiptURLZ : (NSURL *)object NS_AVAILABLE;
-
-// Do not infer a property.
-- (id) t1 NORETURN NS_AVAILABLE;
-- (void) setT1 : (id) arg NS_AVAILABLE;
-
- at property (nonatomic, strong) id method1 ALIGNED NS_AVAILABLE;
-
-- (NSURL *)init; // No Change
-+ (id)alloc; // No Change
-
-- (BOOL)is1stClass; // Not a valid property
- at property (nonatomic, getter=isClass, readonly) BOOL class; // This is a valid property 'class' is not a keyword in ObjC
-- (BOOL)isDouble; // Not a valid property
-
- at end
-
- at class NSMutableDictionary;
-
- at interface NSArray
- at property (nonatomic, readonly, copy) id (^expressionBlock)(id, NSArray *, NSMutableDictionary *);
- at property (nonatomic, copy) id (^MyBlock)(id, NSArray *, NSMutableDictionary *);
- at property (nonatomic, readonly) id (*expressionFuncptr)(id, NSArray *, NSMutableDictionary *);
- at property (nonatomic) id (*MyFuncptr)(id, NSArray *, NSMutableDictionary *);
- at end
-
- at interface rdar15231241
- at property (nonatomic, readonly) double Ddelegate;
- at property (nonatomic, readonly) float Fdelegate;
- at property (nonatomic, readonly) int Idelegate;
- at property (nonatomic, readonly) BOOL Bdelegate;
- at end
-
- at protocol NSObject @end
- at protocol MyProtocol <NSObject>
- at property (nonatomic, readonly, strong) id readonlyProperty;
- at property (nonatomic, strong) id readWriteProperty;
- at end
diff --git a/clang/test/ARCMT/objcmt-protocol-conformance.m b/clang/test/ARCMT/objcmt-protocol-conformance.m
deleted file mode 100644
index e9bb4ac12e6d48..00000000000000
--- a/clang/test/ARCMT/objcmt-protocol-conformance.m
+++ /dev/null
@@ -1,129 +0,0 @@
-// RUN: rm -rf %t
-// RUN: %clang_cc1 -objcmt-migrate-protocol-conformance -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11
-// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c -fobjc-runtime-has-weak -fobjc-arc %s.result
-
- at interface NSObject @end
-
- at protocol P
-- (id) Meth1: (double) arg;
- at end
-
- at interface Test1 // Test for no super class and no protocol list
- at end
-
- at implementation Test1
-- (id) Meth1: (double) arg { return 0; }
- at end
-
- at protocol P1 @end
- at protocol P2 @end
-
- at interface Test2 <P1, P2> // Test for no super class and with protocol list
-{
- id IVAR1;
- id IVAR2;
-}
- at end
-
- at implementation Test2
-- (id) Meth1: (double) arg { return 0; }
- at end
-
- at interface Test3 : NSObject { // Test for Super class and no protocol list
- id IV1;
-}
- at end
-
- at implementation Test3
-- (id) Meth1: (double) arg { return 0; }
- at end
-
- at interface Test4 : NSObject <P1, P2> // Test for Super class and protocol list
- at end
-
- at implementation Test4
-- (id) Meth1: (double) arg { return 0; }
- at end
-
-// Test5 - conforms to P3 because it implement's P3's property.
- at protocol P3
- at property (copy) id Prop;
- at end
-
- at protocol P4
- at property (copy) id Prop;
- at end
-
- at interface Test5 : NSObject<P3>
- at end
-
- at implementation Test5
- at synthesize Prop=_XXX;
- at end
-
- at protocol P5 <P3, P4>
- at property (copy) id Prop;
- at end
-
- at protocol P6 <P3, P4, P5>
- at property (copy) id Prop;
- at end
-
- at interface Test6 : NSObject // Test for minimal listing of conforming protocols
- at property (copy) id Prop;
- at end
-
- at implementation Test6
- at end
-
- at class UIDynamicAnimator, UIWindow;
- at interface UIResponder : NSObject
- at end
-
- at protocol EmptyProtocol
- at end
-
- at protocol OptionalMethodsOnly
- at optional
-- (void)dynamicAnimatorWillResume:(UIDynamicAnimator*)animator;
-- (void)dynamicAnimatorDidPause:(UIDynamicAnimator*)animator;
- at end
-
- at protocol OptionalPropertiesOnly
- at optional
- at property (strong, nonatomic) id OptionalProperty;
- at end
-
- at protocol OptionalEvrything
- at optional
-- (void)dynamicAnimatorWillResume:(UIDynamicAnimator*)animator;
- at property (strong, nonatomic) id OptionalProperty;
-- (void)dynamicAnimatorDidPause:(UIDynamicAnimator*)animator;
- at end
-
- at protocol UIApplicationDelegate
- at end
-
- at interface Test7 : UIResponder <UIApplicationDelegate>
- at property (strong, nonatomic) UIWindow *window;
- at end
-
- at implementation Test7
- at end
-
- at interface BTLEBrowser
- at end
-
- at protocol CBCentralManagerDelegate;
-
- at protocol CBCentralManagerDelegate
-- (id) Meth1: (double) arg;
- at end
-
- at interface BTLEBrowser() <CBCentralManagerDelegate>
- at end
-
- at implementation BTLEBrowser
-- (id) Meth15515206: (double) arg { return 0; }
- at end
diff --git a/clang/test/ARCMT/objcmt-protocol-conformance.m.result b/clang/test/ARCMT/objcmt-protocol-conformance.m.result
deleted file mode 100644
index 987532544bc64b..00000000000000
--- a/clang/test/ARCMT/objcmt-protocol-conformance.m.result
+++ /dev/null
@@ -1,129 +0,0 @@
-// RUN: rm -rf %t
-// RUN: %clang_cc1 -objcmt-migrate-protocol-conformance -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11
-// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c -fobjc-runtime-has-weak -fobjc-arc %s.result
-
- at interface NSObject @end
-
- at protocol P
-- (id) Meth1: (double) arg;
- at end
-
- at interface Test1<P> // Test for no super class and no protocol list
- at end
-
- at implementation Test1
-- (id) Meth1: (double) arg { return 0; }
- at end
-
- at protocol P1 @end
- at protocol P2 @end
-
- at interface Test2 <P1, P2, P> // Test for no super class and with protocol list
-{
- id IVAR1;
- id IVAR2;
-}
- at end
-
- at implementation Test2
-- (id) Meth1: (double) arg { return 0; }
- at end
-
- at interface Test3 : NSObject<P> { // Test for Super class and no protocol list
- id IV1;
-}
- at end
-
- at implementation Test3
-- (id) Meth1: (double) arg { return 0; }
- at end
-
- at interface Test4 : NSObject <P1, P2, P> // Test for Super class and protocol list
- at end
-
- at implementation Test4
-- (id) Meth1: (double) arg { return 0; }
- at end
-
-// Test5 - conforms to P3 because it implement's P3's property.
- at protocol P3
- at property (copy) id Prop;
- at end
-
- at protocol P4
- at property (copy) id Prop;
- at end
-
- at interface Test5 : NSObject<P3, P4>
- at end
-
- at implementation Test5
- at synthesize Prop=_XXX;
- at end
-
- at protocol P5 <P3, P4>
- at property (copy) id Prop;
- at end
-
- at protocol P6 <P3, P4, P5>
- at property (copy) id Prop;
- at end
-
- at interface Test6 : NSObject<P6> // Test for minimal listing of conforming protocols
- at property (copy) id Prop;
- at end
-
- at implementation Test6
- at end
-
- at class UIDynamicAnimator, UIWindow;
- at interface UIResponder : NSObject
- at end
-
- at protocol EmptyProtocol
- at end
-
- at protocol OptionalMethodsOnly
- at optional
-- (void)dynamicAnimatorWillResume:(UIDynamicAnimator*)animator;
-- (void)dynamicAnimatorDidPause:(UIDynamicAnimator*)animator;
- at end
-
- at protocol OptionalPropertiesOnly
- at optional
- at property (strong, nonatomic) id OptionalProperty;
- at end
-
- at protocol OptionalEvrything
- at optional
-- (void)dynamicAnimatorWillResume:(UIDynamicAnimator*)animator;
- at property (strong, nonatomic) id OptionalProperty;
-- (void)dynamicAnimatorDidPause:(UIDynamicAnimator*)animator;
- at end
-
- at protocol UIApplicationDelegate
- at end
-
- at interface Test7 : UIResponder <UIApplicationDelegate>
- at property (strong, nonatomic) UIWindow *window;
- at end
-
- at implementation Test7
- at end
-
- at interface BTLEBrowser
- at end
-
- at protocol CBCentralManagerDelegate;
-
- at protocol CBCentralManagerDelegate
-- (id) Meth1: (double) arg;
- at end
-
- at interface BTLEBrowser() <CBCentralManagerDelegate>
- at end
-
- at implementation BTLEBrowser
-- (id) Meth15515206: (double) arg { return 0; }
- at end
diff --git a/clang/test/ARCMT/objcmt-subscripting-literals-in-arc.m b/clang/test/ARCMT/objcmt-subscripting-literals-in-arc.m
deleted file mode 100644
index 1f56f4a2cf510c..00000000000000
--- a/clang/test/ARCMT/objcmt-subscripting-literals-in-arc.m
+++ /dev/null
@@ -1,108 +0,0 @@
-// RUN: rm -rf %t
-// RUN: %clang_cc1 -fobjc-arc -objcmt-migrate-literals -objcmt-migrate-subscripting -mt-migrate-directory %t %s -x objective-c -triple x86_64-apple-darwin11
-// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result
-// RUN: %clang_cc1 -fobjc-arc -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s.result
-
-typedef signed char BOOL;
-#define nil ((void*) 0)
-
-typedef const struct __CFString * CFStringRef;
-
- at interface NSObject
-+ (id)alloc;
- at end
-
- at protocol NSCopying
- at end
-
- at interface NSString : NSObject
-+ (id)stringWithString:(NSString *)string;
-- (id)initWithString:(NSString *)aString;
- at end
-
- at interface NSArray : NSObject
-- (id)objectAtIndex:(unsigned long)index;
- at end
-
- at interface NSArray (NSExtendedArray)
-- (id)objectAtIndexedSubscript:(unsigned)idx;
- at end
-
- at interface NSArray (NSArrayCreation)
-+ (id)array;
-+ (id)arrayWithObject:(id)anObject;
-+ (id)arrayWithObjects:(const id [])objects count:(unsigned long)cnt;
-+ (id)arrayWithObjects:(id)firstObj, ...;
-+ (id)arrayWithArray:(NSArray *)array;
-
-- (id)initWithObjects:(const id [])objects count:(unsigned long)cnt;
-- (id)initWithObjects:(id)firstObj, ...;
-- (id)initWithArray:(NSArray *)array;
- at end
-
- at interface NSMutableArray : NSArray
-- (void)replaceObjectAtIndex:(unsigned long)index withObject:(id)anObject;
- at end
-
- at interface NSMutableArray (NSExtendedMutableArray)
-- (void)setObject:(id)obj atIndexedSubscript:(unsigned)idx;
- at end
-
- at interface NSDictionary : NSObject
-- (id)objectForKey:(id)aKey;
- at end
-
- at interface NSDictionary (NSExtendedDictionary)
-- (id)objectForKeyedSubscript:(id)key;
- at end
-
- at interface NSDictionary (NSDictionaryCreation)
-+ (id)dictionary;
-+ (id)dictionaryWithObject:(id)object forKey:(id)key;
-+ (id)dictionaryWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt;
-+ (id)dictionaryWithObjectsAndKeys:(id)firstObject, ...;
-+ (id)dictionaryWithDictionary:(NSDictionary *)dict;
-+ (id)dictionaryWithObjects:(NSArray *)objects forKeys:(NSArray *)keys;
-
-- (id)initWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt;
-- (id)initWithObjectsAndKeys:(id)firstObject, ...;
-- (id)initWithDictionary:(NSDictionary *)otherDictionary;
-- (id)initWithObjects:(NSArray *)objects forKeys:(NSArray *)keys;
- at end
-
- at interface NSMutableDictionary : NSDictionary
-- (void)setObject:(id)anObject forKey:(id)aKey;
- at end
-
- at interface NSMutableDictionary (NSExtendedMutableDictionary)
-- (void)setObject:(id)obj forKeyedSubscript:(id <NSCopying>)key;
- at end
-
- at interface NSNumber : NSObject
- at end
-
- at interface NSNumber (NSNumberCreation)
-+ (NSNumber *)numberWithInt:(int)value;
-- (id)initWithInt:(int)value;
- at end
-
- at interface I {
- NSArray *ivarArr;
-}
- at end
- at implementation I
--(void) foo {
- NSString *str;
- NSArray *arr;
- NSDictionary *dict;
-
- arr = [NSArray arrayWithObjects:str, str, nil];
- arr = [[NSArray alloc] initWithObjects:str, str, nil];
- dict = [NSDictionary dictionaryWithObjectsAndKeys: @"value1", @"key1", @"value2", @"key2", nil];
- dict = [[NSDictionary alloc] initWithObjectsAndKeys: @"value1", @"key1", @"value2", @"key2", nil];
-
- dict = [[NSDictionary alloc] initWithObjects:[[NSArray alloc] initWithObjects:@"1", @"2", nil] forKeys:[NSArray arrayWithObjects:@"A", @"B", nil]];
-
- NSNumber *n = [[NSNumber alloc] initWithInt:2];
-}
- at end
diff --git a/clang/test/ARCMT/objcmt-subscripting-literals-in-arc.m.result b/clang/test/ARCMT/objcmt-subscripting-literals-in-arc.m.result
deleted file mode 100644
index d974a2564d4302..00000000000000
--- a/clang/test/ARCMT/objcmt-subscripting-literals-in-arc.m.result
+++ /dev/null
@@ -1,108 +0,0 @@
-// RUN: rm -rf %t
-// RUN: %clang_cc1 -fobjc-arc -objcmt-migrate-literals -objcmt-migrate-subscripting -mt-migrate-directory %t %s -x objective-c -triple x86_64-apple-darwin11
-// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result
-// RUN: %clang_cc1 -fobjc-arc -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s.result
-
-typedef signed char BOOL;
-#define nil ((void*) 0)
-
-typedef const struct __CFString * CFStringRef;
-
- at interface NSObject
-+ (id)alloc;
- at end
-
- at protocol NSCopying
- at end
-
- at interface NSString : NSObject
-+ (id)stringWithString:(NSString *)string;
-- (id)initWithString:(NSString *)aString;
- at end
-
- at interface NSArray : NSObject
-- (id)objectAtIndex:(unsigned long)index;
- at end
-
- at interface NSArray (NSExtendedArray)
-- (id)objectAtIndexedSubscript:(unsigned)idx;
- at end
-
- at interface NSArray (NSArrayCreation)
-+ (id)array;
-+ (id)arrayWithObject:(id)anObject;
-+ (id)arrayWithObjects:(const id [])objects count:(unsigned long)cnt;
-+ (id)arrayWithObjects:(id)firstObj, ...;
-+ (id)arrayWithArray:(NSArray *)array;
-
-- (id)initWithObjects:(const id [])objects count:(unsigned long)cnt;
-- (id)initWithObjects:(id)firstObj, ...;
-- (id)initWithArray:(NSArray *)array;
- at end
-
- at interface NSMutableArray : NSArray
-- (void)replaceObjectAtIndex:(unsigned long)index withObject:(id)anObject;
- at end
-
- at interface NSMutableArray (NSExtendedMutableArray)
-- (void)setObject:(id)obj atIndexedSubscript:(unsigned)idx;
- at end
-
- at interface NSDictionary : NSObject
-- (id)objectForKey:(id)aKey;
- at end
-
- at interface NSDictionary (NSExtendedDictionary)
-- (id)objectForKeyedSubscript:(id)key;
- at end
-
- at interface NSDictionary (NSDictionaryCreation)
-+ (id)dictionary;
-+ (id)dictionaryWithObject:(id)object forKey:(id)key;
-+ (id)dictionaryWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt;
-+ (id)dictionaryWithObjectsAndKeys:(id)firstObject, ...;
-+ (id)dictionaryWithDictionary:(NSDictionary *)dict;
-+ (id)dictionaryWithObjects:(NSArray *)objects forKeys:(NSArray *)keys;
-
-- (id)initWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt;
-- (id)initWithObjectsAndKeys:(id)firstObject, ...;
-- (id)initWithDictionary:(NSDictionary *)otherDictionary;
-- (id)initWithObjects:(NSArray *)objects forKeys:(NSArray *)keys;
- at end
-
- at interface NSMutableDictionary : NSDictionary
-- (void)setObject:(id)anObject forKey:(id)aKey;
- at end
-
- at interface NSMutableDictionary (NSExtendedMutableDictionary)
-- (void)setObject:(id)obj forKeyedSubscript:(id <NSCopying>)key;
- at end
-
- at interface NSNumber : NSObject
- at end
-
- at interface NSNumber (NSNumberCreation)
-+ (NSNumber *)numberWithInt:(int)value;
-- (id)initWithInt:(int)value;
- at end
-
- at interface I {
- NSArray *ivarArr;
-}
- at end
- at implementation I
--(void) foo {
- NSString *str;
- NSArray *arr;
- NSDictionary *dict;
-
- arr = @[str, str];
- arr = @[str, str];
- dict = @{@"key1": @"value1", @"key2": @"value2"};
- dict = @{@"key1": @"value1", @"key2": @"value2"};
-
- dict = @{@"A": @"1", @"B": @"2"};
-
- NSNumber *n = @2;
-}
- at end
diff --git a/clang/test/ARCMT/objcmt-subscripting-literals.m b/clang/test/ARCMT/objcmt-subscripting-literals.m
deleted file mode 100644
index e2b03e2d7b587d..00000000000000
--- a/clang/test/ARCMT/objcmt-subscripting-literals.m
+++ /dev/null
@@ -1,230 +0,0 @@
-// RUN: rm -rf %t
-// RUN: %clang_cc1 -objcmt-migrate-literals -objcmt-migrate-subscripting -mt-migrate-directory %t %s -x objective-c -triple x86_64-apple-darwin11
-// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s.result
-
-typedef signed char BOOL;
-#define nil ((void*) 0)
-
-typedef const struct __CFString * CFStringRef;
-
- at interface NSObject
-+ (id)alloc;
- at end
-
- at protocol NSCopying
- at end
-
- at interface NSString : NSObject
-+ (id)stringWithString:(NSString *)string;
-- (id)initWithString:(NSString *)aString;
- at end
-
- at interface NSArray : NSObject
-- (id)objectAtIndex:(unsigned long)index;
- at end
-
- at interface NSArray (NSExtendedArray)
-- (id)objectAtIndexedSubscript:(unsigned)idx;
- at end
-
- at interface NSArray (NSArrayCreation)
-+ (id)array;
-+ (id)arrayWithObject:(id)anObject;
-+ (id)arrayWithObjects:(const id [])objects count:(unsigned long)cnt;
-+ (id)arrayWithObjects:(id)firstObj, ...;
-+ (id)arrayWithArray:(NSArray *)array;
-
-- (id)initWithObjects:(const id [])objects count:(unsigned long)cnt;
-- (id)initWithObjects:(id)firstObj, ...;
-- (id)initWithArray:(NSArray *)array;
- at end
-
- at interface NSMutableArray : NSArray
-- (void)replaceObjectAtIndex:(unsigned long)index withObject:(id)anObject;
- at end
-
- at interface NSMutableArray (NSExtendedMutableArray)
-- (void)setObject:(id)obj atIndexedSubscript:(unsigned)idx;
- at end
-
- at interface NSDictionary : NSObject
-- (id)objectForKey:(id)aKey;
- at end
-
- at interface NSDictionary (NSExtendedDictionary)
-- (id)objectForKeyedSubscript:(id)key;
- at end
-
- at interface NSDictionary (NSDictionaryCreation)
-+ (id)dictionary;
-+ (id)dictionaryWithObject:(id)object forKey:(id)key;
-+ (id)dictionaryWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt;
-+ (id)dictionaryWithObjectsAndKeys:(id)firstObject, ...;
-+ (id)dictionaryWithDictionary:(NSDictionary *)dict;
-+ (id)dictionaryWithObjects:(NSArray *)objects forKeys:(NSArray *)keys;
-
-- (id)initWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt;
-- (id)initWithObjectsAndKeys:(id)firstObject, ...;
-- (id)initWithDictionary:(NSDictionary *)otherDictionary;
-- (id)initWithObjects:(NSArray *)objects forKeys:(NSArray *)keys;
- at end
-
- at interface NSMutableDictionary : NSDictionary
-- (void)setObject:(id)anObject forKey:(id)aKey;
- at end
-
- at interface NSMutableDictionary (NSExtendedMutableDictionary)
-- (void)setObject:(id)obj forKeyedSubscript:(id <NSCopying>)key;
- at end
-
- at interface NSNumber : NSObject
- at end
-
- at interface NSNumber (NSNumberCreation)
-+ (NSNumber *)numberWithInt:(int)value;
- at end
-
-#define M(x) (x)
-#define PAIR(x) @#x, [NSNumber numberWithInt:(x)]
-#define TWO(x) ((x), (x))
-#define TWO_SEP(x,y) ((x), (y))
-
- at interface I {
- NSArray *ivarArr;
-}
- at end
- at implementation I
--(void) foo {
- NSString *str;
- NSArray *arr;
- NSDictionary *dict;
-
- arr = [NSArray array];
- arr = [NSArray arrayWithObject:str];
- arr = [NSArray arrayWithObjects:str, str, nil];
- dict = [NSDictionary dictionary];
- dict = [NSDictionary dictionaryWithObject:arr forKey:str];
- dict = [NSDictionary dictionaryWithObjectsAndKeys: @"value1", @"key1", @"value2", @"key2", nil];
- dict = [NSDictionary dictionaryWithObjectsAndKeys: PAIR(1), PAIR(2), nil];
- dict = [NSDictionary dictionaryWithObjectsAndKeys:
- @"value1", @"key1",
-#ifdef BLAH
- @"value2", @"key2",
-#else
- @"value3", @"key3",
-#endif
- nil ];
-
- id o = [arr objectAtIndex:2];
- o = [dict objectForKey:@"key"];
- o = TWO([dict objectForKey:@"key"]);
- o = TWO_SEP([dict objectForKey:@"key"], [arr objectAtIndex:2]);
- o = [NSDictionary dictionaryWithObject:[NSDictionary dictionary] forKey:@"key"];
- NSMutableArray *marr = 0;
- NSMutableDictionary *mdict = 0;
- [marr replaceObjectAtIndex:2 withObject:@"val"];
- [mdict setObject:@"value" forKey:@"key"];
- [marr replaceObjectAtIndex:2 withObject:[arr objectAtIndex:4]];
- [mdict setObject:[dict objectForKey:@"key2"] forKey:@"key"];
- [mdict setObject:[dict objectForKey:@"key2"] forKey:
-#if 1
- @"key1"
-#else
- @"key2"
-#endif
- ];
- [mdict setObject:[dict objectForKey:
-#if 2
- @"key3"
-#else
- @"key4"
-#endif
- ] forKey:@"key"];
- [mdict setObject:@"value" forKey:[dict objectForKey:
-#if 3
- @"key5"
-#else
- @"key6"
-#endif
- ] ];
- [mdict setObject:@"val" forKey:[dict objectForKey:@"key2"]];
- [mdict setObject:[dict objectForKey:@"key1"] forKey:[dict objectForKey:[NSArray arrayWithObject:@"arrkey"]]];
- __strong NSArray **parr = 0;
- o = [*parr objectAtIndex:2];
- void *hd;
- o = [(NSArray*)hd objectAtIndex:2];
- o = [ivarArr objectAtIndex:2];
-
- dict = [NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:@"1", [NSArray array], nil] forKeys:[NSArray arrayWithObjects:@"A", [arr objectAtIndex:2], nil]];
- dict = [NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:@"1", @"2", nil] forKeys:arr];
- dict = [NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:@"1", @"2", nil] forKeys:@[@"A", @"B"]];
- dict = [NSDictionary dictionaryWithObjectsAndKeys:[NSArray array], @"A", [NSArray array], @"B", nil];
-}
- at end
-
-extern const CFStringRef globStr;
-
-void test1(NSString *str) {
- NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys: str, globStr, nil];
- dict = [NSDictionary dictionaryWithObjectsAndKeys: globStr, str, nil];
- dict = [NSDictionary dictionaryWithObject:str forKey:globStr];
- dict = [NSDictionary dictionaryWithObject:globStr forKey:str];
-
- NSArray *arr = [NSArray arrayWithObjects: globStr, globStr, nil];
- arr = [NSArray arrayWithObjects: str, globStr, nil];
- arr = [NSArray arrayWithObjects: globStr, str, nil];
- arr = [NSArray arrayWithObject:globStr];
-}
-
- at interface Custom : NSObject
-- (id)objectAtIndex:(unsigned long)index;
- at end
-
- at interface Custom (Extended)
-- (id)objectAtIndexedSubscript:(unsigned)idx;
- at end
-
- at interface MutableCustom : Custom
-- (void)replaceObjectAtIndex:(unsigned long)index withObject:(id)anObject;
- at end
-
- at interface MutableCustom (Extended)
-- (void)setObject:(id)obj atIndexedSubscript:(unsigned)idx;
- at end
-
- at interface CustomUnavail : NSObject
-- (id)objectAtIndex:(unsigned long)index;
- at end
-
- at interface CustomUnavail (Extended)
-- (id)objectAtIndexedSubscript:(unsigned)idx __attribute__((unavailable));
- at end
-
- at interface MutableCustomUnavail : CustomUnavail
-- (void)replaceObjectAtIndex:(unsigned long)index withObject:(id)anObject;
- at end
-
- at interface MutableCustomUnavail (Extended)
-- (void)setObject:(id)obj atIndexedSubscript:(unsigned)idx __attribute__((unavailable));
- at end
-
-void test2(void) {
- MutableCustom *mutc;
- id o = [mutc objectAtIndex:4];
- [mutc replaceObjectAtIndex:2 withObject:@"val"];
-
- MutableCustomUnavail *mutcunaval;
- o = [mutcunaval objectAtIndex:4];
- [mutcunaval replaceObjectAtIndex:2 withObject:@"val"];
-}
-
- at interface NSLocale : NSObject
-+ (id)systemLocale;
-+ (id)currentLocale;
-- (id)objectForKey:(id)key;
- at end
-
-void test3(id key) {
- id o = [[NSLocale currentLocale] objectForKey:key];
-}
diff --git a/clang/test/ARCMT/objcmt-subscripting-literals.m.result b/clang/test/ARCMT/objcmt-subscripting-literals.m.result
deleted file mode 100644
index e0b385741f01ed..00000000000000
--- a/clang/test/ARCMT/objcmt-subscripting-literals.m.result
+++ /dev/null
@@ -1,230 +0,0 @@
-// RUN: rm -rf %t
-// RUN: %clang_cc1 -objcmt-migrate-literals -objcmt-migrate-subscripting -mt-migrate-directory %t %s -x objective-c -triple x86_64-apple-darwin11
-// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s.result
-
-typedef signed char BOOL;
-#define nil ((void*) 0)
-
-typedef const struct __CFString * CFStringRef;
-
- at interface NSObject
-+ (id)alloc;
- at end
-
- at protocol NSCopying
- at end
-
- at interface NSString : NSObject
-+ (id)stringWithString:(NSString *)string;
-- (id)initWithString:(NSString *)aString;
- at end
-
- at interface NSArray : NSObject
-- (id)objectAtIndex:(unsigned long)index;
- at end
-
- at interface NSArray (NSExtendedArray)
-- (id)objectAtIndexedSubscript:(unsigned)idx;
- at end
-
- at interface NSArray (NSArrayCreation)
-+ (id)array;
-+ (id)arrayWithObject:(id)anObject;
-+ (id)arrayWithObjects:(const id [])objects count:(unsigned long)cnt;
-+ (id)arrayWithObjects:(id)firstObj, ...;
-+ (id)arrayWithArray:(NSArray *)array;
-
-- (id)initWithObjects:(const id [])objects count:(unsigned long)cnt;
-- (id)initWithObjects:(id)firstObj, ...;
-- (id)initWithArray:(NSArray *)array;
- at end
-
- at interface NSMutableArray : NSArray
-- (void)replaceObjectAtIndex:(unsigned long)index withObject:(id)anObject;
- at end
-
- at interface NSMutableArray (NSExtendedMutableArray)
-- (void)setObject:(id)obj atIndexedSubscript:(unsigned)idx;
- at end
-
- at interface NSDictionary : NSObject
-- (id)objectForKey:(id)aKey;
- at end
-
- at interface NSDictionary (NSExtendedDictionary)
-- (id)objectForKeyedSubscript:(id)key;
- at end
-
- at interface NSDictionary (NSDictionaryCreation)
-+ (id)dictionary;
-+ (id)dictionaryWithObject:(id)object forKey:(id)key;
-+ (id)dictionaryWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt;
-+ (id)dictionaryWithObjectsAndKeys:(id)firstObject, ...;
-+ (id)dictionaryWithDictionary:(NSDictionary *)dict;
-+ (id)dictionaryWithObjects:(NSArray *)objects forKeys:(NSArray *)keys;
-
-- (id)initWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt;
-- (id)initWithObjectsAndKeys:(id)firstObject, ...;
-- (id)initWithDictionary:(NSDictionary *)otherDictionary;
-- (id)initWithObjects:(NSArray *)objects forKeys:(NSArray *)keys;
- at end
-
- at interface NSMutableDictionary : NSDictionary
-- (void)setObject:(id)anObject forKey:(id)aKey;
- at end
-
- at interface NSMutableDictionary (NSExtendedMutableDictionary)
-- (void)setObject:(id)obj forKeyedSubscript:(id <NSCopying>)key;
- at end
-
- at interface NSNumber : NSObject
- at end
-
- at interface NSNumber (NSNumberCreation)
-+ (NSNumber *)numberWithInt:(int)value;
- at end
-
-#define M(x) (x)
-#define PAIR(x) @#x, [NSNumber numberWithInt:(x)]
-#define TWO(x) ((x), (x))
-#define TWO_SEP(x,y) ((x), (y))
-
- at interface I {
- NSArray *ivarArr;
-}
- at end
- at implementation I
--(void) foo {
- NSString *str;
- NSArray *arr;
- NSDictionary *dict;
-
- arr = @[];
- arr = @[str];
- arr = @[str, str];
- dict = @{};
- dict = @{str: arr};
- dict = @{@"key1": @"value1", @"key2": @"value2"};
- dict = [NSDictionary dictionaryWithObjectsAndKeys: PAIR(1), PAIR(2), nil];
- dict = [NSDictionary dictionaryWithObjectsAndKeys:
- @"value1", @"key1",
-#ifdef BLAH
- @"value2", @"key2",
-#else
- @"value3", @"key3",
-#endif
- nil ];
-
- id o = arr[2];
- o = dict[@"key"];
- o = TWO(dict[@"key"]);
- o = TWO_SEP(dict[@"key"], arr[2]);
- o = @{@"key": @{}};
- NSMutableArray *marr = 0;
- NSMutableDictionary *mdict = 0;
- marr[2] = @"val";
- mdict[@"key"] = @"value";
- marr[2] = arr[4];
- mdict[@"key"] = dict[@"key2"];
- [mdict setObject:dict[@"key2"] forKey:
-#if 1
- @"key1"
-#else
- @"key2"
-#endif
- ];
- mdict[@"key"] = [dict objectForKey:
-#if 2
- @"key3"
-#else
- @"key4"
-#endif
- ];
- mdict[[dict objectForKey:
-#if 3
- @"key5"
-#else
- @"key6"
-#endif
- ]] = @"value";
- mdict[dict[@"key2"]] = @"val";
- mdict[dict[@[@"arrkey"]]] = dict[@"key1"];
- __strong NSArray **parr = 0;
- o = (*parr)[2];
- void *hd;
- o = ((NSArray*)hd)[2];
- o = ivarArr[2];
-
- dict = @{@"A": @"1", arr[2]: @[]};
- dict = [NSDictionary dictionaryWithObjects:@[@"1", @"2"] forKeys:arr];
- dict = @{@"A": @"1", @"B": @"2"};
- dict = @{@"A": @[], @"B": @[]};
-}
- at end
-
-extern const CFStringRef globStr;
-
-void test1(NSString *str) {
- NSDictionary *dict = @{(id)globStr: str};
- dict = @{str: (id)globStr};
- dict = @{(id)globStr: str};
- dict = @{str: (id)globStr};
-
- NSArray *arr = @[(id)globStr, (id)globStr];
- arr = @[str, (id)globStr];
- arr = @[(id)globStr, str];
- arr = @[(id)globStr];
-}
-
- at interface Custom : NSObject
-- (id)objectAtIndex:(unsigned long)index;
- at end
-
- at interface Custom (Extended)
-- (id)objectAtIndexedSubscript:(unsigned)idx;
- at end
-
- at interface MutableCustom : Custom
-- (void)replaceObjectAtIndex:(unsigned long)index withObject:(id)anObject;
- at end
-
- at interface MutableCustom (Extended)
-- (void)setObject:(id)obj atIndexedSubscript:(unsigned)idx;
- at end
-
- at interface CustomUnavail : NSObject
-- (id)objectAtIndex:(unsigned long)index;
- at end
-
- at interface CustomUnavail (Extended)
-- (id)objectAtIndexedSubscript:(unsigned)idx __attribute__((unavailable));
- at end
-
- at interface MutableCustomUnavail : CustomUnavail
-- (void)replaceObjectAtIndex:(unsigned long)index withObject:(id)anObject;
- at end
-
- at interface MutableCustomUnavail (Extended)
-- (void)setObject:(id)obj atIndexedSubscript:(unsigned)idx __attribute__((unavailable));
- at end
-
-void test2(void) {
- MutableCustom *mutc;
- id o = mutc[4];
- mutc[2] = @"val";
-
- MutableCustomUnavail *mutcunaval;
- o = [mutcunaval objectAtIndex:4];
- [mutcunaval replaceObjectAtIndex:2 withObject:@"val"];
-}
-
- at interface NSLocale : NSObject
-+ (id)systemLocale;
-+ (id)currentLocale;
-- (id)objectForKey:(id)key;
- at end
-
-void test3(id key) {
- id o = [[NSLocale currentLocale] objectForKey:key];
-}
diff --git a/clang/test/ARCMT/objcmt-subscripting-unavailable.m b/clang/test/ARCMT/objcmt-subscripting-unavailable.m
deleted file mode 100644
index d72c362e30f4ff..00000000000000
--- a/clang/test/ARCMT/objcmt-subscripting-unavailable.m
+++ /dev/null
@@ -1,79 +0,0 @@
-// RUN: rm -rf %t
-// RUN: %clang_cc1 -objcmt-migrate-literals -objcmt-migrate-subscripting -mt-migrate-directory %t %s -x objective-c -triple x86_64-apple-darwin11
-// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s.result
-
-typedef signed char BOOL;
-#define nil ((void*) 0)
-
- at interface NSObject
-+ (id)alloc;
- at end
-
- at interface NSArray : NSObject
-- (id)objectAtIndex:(unsigned long)index;
- at end
-
- at interface NSArray (NSArrayCreation)
-+ (id)array;
-+ (id)arrayWithObject:(id)anObject;
-+ (id)arrayWithObjects:(const id [])objects count:(unsigned long)cnt;
-+ (id)arrayWithObjects:(id)firstObj, ...;
-+ (id)arrayWithArray:(NSArray *)array;
-
-- (id)initWithObjects:(const id [])objects count:(unsigned long)cnt;
-- (id)initWithObjects:(id)firstObj, ...;
-- (id)initWithArray:(NSArray *)array;
- at end
-
- at interface NSMutableArray : NSArray
-- (void)replaceObjectAtIndex:(unsigned long)index withObject:(id)anObject;
- at end
-
- at interface NSDictionary : NSObject
- at end
-
- at interface NSDictionary (NSDictionaryCreation)
-+ (id)dictionary;
-+ (id)dictionaryWithObject:(id)object forKey:(id)key;
-+ (id)dictionaryWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt;
-+ (id)dictionaryWithObjectsAndKeys:(id)firstObject, ...;
-+ (id)dictionaryWithDictionary:(NSDictionary *)dict;
-+ (id)dictionaryWithObjects:(NSArray *)objects forKeys:(NSArray *)keys;
-
-- (id)initWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt;
-- (id)initWithObjectsAndKeys:(id)firstObject, ...;
-- (id)initWithDictionary:(NSDictionary *)otherDictionary;
-- (id)initWithObjects:(NSArray *)objects forKeys:(NSArray *)keys;
-
-- (id)objectForKey:(id)aKey;
- at end
-
- at interface NSMutableDictionary : NSDictionary
-- (void)setObject:(id)anObject forKey:(id)aKey;
- at end
-
- at interface I
- at end
- at implementation I
--(void) foo {
- id str;
- NSArray *arr;
- NSDictionary *dict;
-
- arr = [NSArray array];
- arr = [NSArray arrayWithObject:str];
- arr = [NSArray arrayWithObjects:str, str, nil];
- dict = [NSDictionary dictionary];
- dict = [NSDictionary dictionaryWithObject:arr forKey:str];
-
- id o = [arr objectAtIndex:2];
- o = [dict objectForKey:@"key"];
- NSMutableArray *marr = 0;
- NSMutableDictionary *mdict = 0;
- [marr replaceObjectAtIndex:2 withObject:@"val"];
- [mdict setObject:@"value" forKey:@"key"];
- [marr replaceObjectAtIndex:2 withObject:[arr objectAtIndex:4]];
- [mdict setObject:[dict objectForKey:@"key2"] forKey:@"key"];
-}
- at end
diff --git a/clang/test/ARCMT/objcmt-subscripting-unavailable.m.result b/clang/test/ARCMT/objcmt-subscripting-unavailable.m.result
deleted file mode 100644
index bd74d558386080..00000000000000
--- a/clang/test/ARCMT/objcmt-subscripting-unavailable.m.result
+++ /dev/null
@@ -1,79 +0,0 @@
-// RUN: rm -rf %t
-// RUN: %clang_cc1 -objcmt-migrate-literals -objcmt-migrate-subscripting -mt-migrate-directory %t %s -x objective-c -triple x86_64-apple-darwin11
-// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s.result
-
-typedef signed char BOOL;
-#define nil ((void*) 0)
-
- at interface NSObject
-+ (id)alloc;
- at end
-
- at interface NSArray : NSObject
-- (id)objectAtIndex:(unsigned long)index;
- at end
-
- at interface NSArray (NSArrayCreation)
-+ (id)array;
-+ (id)arrayWithObject:(id)anObject;
-+ (id)arrayWithObjects:(const id [])objects count:(unsigned long)cnt;
-+ (id)arrayWithObjects:(id)firstObj, ...;
-+ (id)arrayWithArray:(NSArray *)array;
-
-- (id)initWithObjects:(const id [])objects count:(unsigned long)cnt;
-- (id)initWithObjects:(id)firstObj, ...;
-- (id)initWithArray:(NSArray *)array;
- at end
-
- at interface NSMutableArray : NSArray
-- (void)replaceObjectAtIndex:(unsigned long)index withObject:(id)anObject;
- at end
-
- at interface NSDictionary : NSObject
- at end
-
- at interface NSDictionary (NSDictionaryCreation)
-+ (id)dictionary;
-+ (id)dictionaryWithObject:(id)object forKey:(id)key;
-+ (id)dictionaryWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt;
-+ (id)dictionaryWithObjectsAndKeys:(id)firstObject, ...;
-+ (id)dictionaryWithDictionary:(NSDictionary *)dict;
-+ (id)dictionaryWithObjects:(NSArray *)objects forKeys:(NSArray *)keys;
-
-- (id)initWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt;
-- (id)initWithObjectsAndKeys:(id)firstObject, ...;
-- (id)initWithDictionary:(NSDictionary *)otherDictionary;
-- (id)initWithObjects:(NSArray *)objects forKeys:(NSArray *)keys;
-
-- (id)objectForKey:(id)aKey;
- at end
-
- at interface NSMutableDictionary : NSDictionary
-- (void)setObject:(id)anObject forKey:(id)aKey;
- at end
-
- at interface I
- at end
- at implementation I
--(void) foo {
- id str;
- NSArray *arr;
- NSDictionary *dict;
-
- arr = @[];
- arr = @[str];
- arr = @[str, str];
- dict = @{};
- dict = @{str: arr};
-
- id o = [arr objectAtIndex:2];
- o = [dict objectForKey:@"key"];
- NSMutableArray *marr = 0;
- NSMutableDictionary *mdict = 0;
- [marr replaceObjectAtIndex:2 withObject:@"val"];
- [mdict setObject:@"value" forKey:@"key"];
- [marr replaceObjectAtIndex:2 withObject:[arr objectAtIndex:4]];
- [mdict setObject:[dict objectForKey:@"key2"] forKey:@"key"];
-}
- at end
diff --git a/clang/test/ARCMT/objcmt-undefined-ns-macros.m b/clang/test/ARCMT/objcmt-undefined-ns-macros.m
deleted file mode 100644
index 473b49589222da..00000000000000
--- a/clang/test/ARCMT/objcmt-undefined-ns-macros.m
+++ /dev/null
@@ -1,22 +0,0 @@
-// RUN: rm -rf %t
-// RUN: %clang_cc1 -fmodules -objcmt-migrate-ns-macros -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11
-// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result
-
-typedef long NSInteger;
-enum {
- UIViewNone = 0x0,
- UIViewMargin = 0x1,
- UIViewWidth = 0x2,
- UIViewRightMargin = 0x3,
- UIViewBottomMargin = 0xbadbeef
-};
-typedef NSInteger UITableStyle;
-
-
-typedef
- enum { two = 1 } NumericEnum2;
-
-typedef enum { three = 1 } NumericEnum3;
-
-typedef enum { four = 1 } NumericEnum4;
-
diff --git a/clang/test/ARCMT/objcmt-undefined-ns-macros.m.result b/clang/test/ARCMT/objcmt-undefined-ns-macros.m.result
deleted file mode 100644
index a6942e20795fd0..00000000000000
--- a/clang/test/ARCMT/objcmt-undefined-ns-macros.m.result
+++ /dev/null
@@ -1,24 +0,0 @@
-// RUN: rm -rf %t
-// RUN: %clang_cc1 -fmodules -objcmt-migrate-ns-macros -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11
-// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result
-
-typedef long NSInteger;
-#ifndef NS_ENUM
- at import Foundation;
-#endif
-typedef NS_OPTIONS(NSUInteger, UITableStyle) {
- UIViewNone = 0x0,
- UIViewMargin = 0x1,
- UIViewWidth = 0x2,
- UIViewRightMargin = 0x3,
- UIViewBottomMargin = 0xbadbeef
-};
-
-
-typedef
- NS_ENUM(unsigned int, NumericEnum2) { two = 1 };
-
-typedef NS_ENUM(unsigned int, NumericEnum3) { three = 1 };
-
-typedef NS_ENUM(unsigned int, NumericEnum4) { four = 1 };
-
diff --git a/clang/test/ARCMT/objcmt-with-pch.m b/clang/test/ARCMT/objcmt-with-pch.m
deleted file mode 100644
index 0925442d45eb97..00000000000000
--- a/clang/test/ARCMT/objcmt-with-pch.m
+++ /dev/null
@@ -1,17 +0,0 @@
-// REQUIRES: x86-registered-target
-// RUN: rm -rf %t
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -x objective-c %S/Common.h -emit-pch -o %t.pch
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -objcmt-migrate-literals -objcmt-migrate-subscripting -mt-migrate-directory %t %s -x objective-c -include-pch %t.pch
-// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s.result -include-pch %t.pch
-
- at interface NSNumber : NSObject
- at end
-
- at interface NSNumber (NSNumberCreation)
-+ (NSNumber *)numberWithInt:(int)value;
- at end
-
-void foo(void) {
- NSNumber *n = [NSNumber numberWithInt:1];
-}
diff --git a/clang/test/ARCMT/objcmt-with-pch.m.result b/clang/test/ARCMT/objcmt-with-pch.m.result
deleted file mode 100644
index 6d37d11fe480d4..00000000000000
--- a/clang/test/ARCMT/objcmt-with-pch.m.result
+++ /dev/null
@@ -1,17 +0,0 @@
-// REQUIRES: x86-registered-target
-// RUN: rm -rf %t
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -x objective-c %S/Common.h -emit-pch -o %t.pch
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -objcmt-migrate-literals -objcmt-migrate-subscripting -mt-migrate-directory %t %s -x objective-c -include-pch %t.pch
-// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s.result -include-pch %t.pch
-
- at interface NSNumber : NSObject
- at end
-
- at interface NSNumber (NSNumberCreation)
-+ (NSNumber *)numberWithInt:(int)value;
- at end
-
-void foo(void) {
- NSNumber *n = @1;
-}
diff --git a/clang/test/ARCMT/protected-scope.m b/clang/test/ARCMT/protected-scope.m
deleted file mode 100644
index b522f54cdf7c16..00000000000000
--- a/clang/test/ARCMT/protected-scope.m
+++ /dev/null
@@ -1,36 +0,0 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result
-// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s > %t
-// RUN: diff %t %s.result
-
-#include "Common.h"
-
-void test(id p, int x) {
- int v;
- switch(x) {
- case 0:
- v++;
- id w1 = p;
- id w2 = p;
- break;
- case 1:
- v++;
- id w3 = p;
- break;
- case 2:
- case 3:
- break;
- default:
- break;
- }
-}
-
-void test2(int p) {
- switch (p) {
- case 3:;
- NSObject *o = [[NSObject alloc] init];
- [o release];
- break;
- default:
- break;
- }
-}
diff --git a/clang/test/ARCMT/protected-scope.m.result b/clang/test/ARCMT/protected-scope.m.result
deleted file mode 100644
index 55070f27322712..00000000000000
--- a/clang/test/ARCMT/protected-scope.m.result
+++ /dev/null
@@ -1,38 +0,0 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result
-// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s > %t
-// RUN: diff %t %s.result
-
-#include "Common.h"
-
-void test(id p, int x) {
- int v;
- switch(x) {
- case 0: {
- v++;
- id w1 = p;
- id w2 = p;
- break;
- }
- case 1: {
- v++;
- id w3 = p;
- break;
- }
- case 2:
- case 3:
- break;
- default:
- break;
- }
-}
-
-void test2(int p) {
- switch (p) {
- case 3: {;
- NSObject *o = [[NSObject alloc] init];
- break;
- }
- default:
- break;
- }
-}
diff --git a/clang/test/ARCMT/releases-driver.m b/clang/test/ARCMT/releases-driver.m
deleted file mode 100644
index 96f96c1d3b4821..00000000000000
--- a/clang/test/ARCMT/releases-driver.m
+++ /dev/null
@@ -1,67 +0,0 @@
-// RUN: %clang_cc1 -fblocks -fsyntax-only -fobjc-arc -x objective-c %s.result
-// RUN: cat %s > %t
-// RUN: %clang_cc1 -arcmt-action=modify -triple x86_64-apple-macosx10.6 -x objective-c %t
-// RUN: diff %t %s.result
-// RUN: rm %t
-
-typedef int BOOL;
-
-id IhaveSideEffect(void);
-
- at protocol NSObject
-- (BOOL)isEqual:(id)object;
-- (id)retain;
-- (oneway void)release;
- at end
-
- at interface NSObject <NSObject> {}
- at end
-
- at interface Foo : NSObject {
- id bar;
-}
- at property (retain) id bar;
--(void)test:(id)obj;
- at end
-
- at implementation Foo
-
- at synthesize bar;
-
--(void)test:(id)obj {
- id x = self.bar;
- [x retain];
- self.bar = obj;
- // do stuff with x;
- [x release];
-
- [IhaveSideEffect() release];
-
- [x release], x = 0;
-}
-
- at end
-
-void func(Foo *p) {
- [p release];
- (([p release]));
-}
-
- at interface Baz {
- id <NSObject> _foo;
-}
- at end
-
- at implementation Baz
-- (void) dealloc {
- [_foo release];
-}
- at end
-
-#define RELEASE_MACRO(x) [x release]
-#define RELEASE_MACRO2(x) RELEASE_MACRO(x)
-
-void test2(id p) {
- RELEASE_MACRO(p);
- RELEASE_MACRO2(p);
-}
diff --git a/clang/test/ARCMT/releases-driver.m.result b/clang/test/ARCMT/releases-driver.m.result
deleted file mode 100644
index e7da9a04fc62ab..00000000000000
--- a/clang/test/ARCMT/releases-driver.m.result
+++ /dev/null
@@ -1,58 +0,0 @@
-// RUN: %clang_cc1 -fblocks -fsyntax-only -fobjc-arc -x objective-c %s.result
-// RUN: cat %s > %t
-// RUN: %clang_cc1 -arcmt-action=modify -triple x86_64-apple-macosx10.6 -x objective-c %t
-// RUN: diff %t %s.result
-// RUN: rm %t
-
-typedef int BOOL;
-
-id IhaveSideEffect(void);
-
- at protocol NSObject
-- (BOOL)isEqual:(id)object;
-- (id)retain;
-- (oneway void)release;
- at end
-
- at interface NSObject <NSObject> {}
- at end
-
- at interface Foo : NSObject {
- id bar;
-}
- at property (strong) id bar;
--(void)test:(id)obj;
- at end
-
- at implementation Foo
-
- at synthesize bar;
-
--(void)test:(id)obj {
- id x = self.bar;
- self.bar = obj;
- // do stuff with x;
-
- IhaveSideEffect();
-
- x = 0;
-}
-
- at end
-
-void func(Foo *p) {
-}
-
- at interface Baz {
- id <NSObject> _foo;
-}
- at end
-
- at implementation Baz
- at end
-
-#define RELEASE_MACRO(x) [x release]
-#define RELEASE_MACRO2(x) RELEASE_MACRO(x)
-
-void test2(id p) {
-}
diff --git a/clang/test/ARCMT/releases.m b/clang/test/ARCMT/releases.m
deleted file mode 100644
index 8636a8a5acea83..00000000000000
--- a/clang/test/ARCMT/releases.m
+++ /dev/null
@@ -1,98 +0,0 @@
-// RUN: %clang_cc1 -fobjc-exceptions -fblocks -fsyntax-only -fobjc-arc -x objective-c %s.result
-// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fobjc-exceptions -fblocks -fsyntax-only -x objective-c %s > %t
-// RUN: diff %t %s.result
-
-#define nil 0
-
-typedef int BOOL;
-
-id IhaveSideEffect(void);
-
- at protocol NSObject
-- (BOOL)isEqual:(id)object;
-- (id)retain;
-- (oneway void)release;
- at end
-
- at interface NSObject <NSObject> {}
- at end
-
- at interface Foo : NSObject {
- id bar;
-}
- at property (retain) id bar;
--(void)test:(id)obj;
- at end
-
- at implementation Foo
-
- at synthesize bar;
-
--(void)test:(id)obj {
- id x = self.bar;
- [x retain];
- self.bar = obj;
- // do stuff with x;
- [x release];
-
- [IhaveSideEffect() release];
-
- [x release], x = 0;
-
- @try {
- } @finally {
- [x release];
- }
-}
-
- at end
-
-void func(Foo *p) {
- [p release];
- (([p release]));
-}
-
- at interface Baz {
- id <NSObject> _foo;
-}
- at end
-
- at implementation Baz
-- (void) dealloc {
- [_foo release];
-}
- at end
-
-void block_test(Foo *p) {
- id (^B)(void) = ^(void) {
- if (p) {
- id (^IB)(void) = ^(void) {
- id bar = [p retain];
- [p release];
- return bar;
- };
- IB();
- }
- return [p retain];
- };
-}
-
-#define RELEASE_MACRO(x) [x release]
-#define RELEASE_MACRO2(x) RELEASE_MACRO(x)
-
-void test2(id p) {
- RELEASE_MACRO(p);
- RELEASE_MACRO2(p);
-}
-
- at implementation Foo2
-
-static id internal_var = 0;
-
-+ (void)setIt:(id)newone {
- if (internal_var != newone) {
- [internal_var release];
- internal_var = [newone retain];
- }
-}
- at end
diff --git a/clang/test/ARCMT/releases.m.result b/clang/test/ARCMT/releases.m.result
deleted file mode 100644
index 261175362b9bdf..00000000000000
--- a/clang/test/ARCMT/releases.m.result
+++ /dev/null
@@ -1,87 +0,0 @@
-// RUN: %clang_cc1 -fobjc-exceptions -fblocks -fsyntax-only -fobjc-arc -x objective-c %s.result
-// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fobjc-exceptions -fblocks -fsyntax-only -x objective-c %s > %t
-// RUN: diff %t %s.result
-
-#define nil 0
-
-typedef int BOOL;
-
-id IhaveSideEffect(void);
-
- at protocol NSObject
-- (BOOL)isEqual:(id)object;
-- (id)retain;
-- (oneway void)release;
- at end
-
- at interface NSObject <NSObject> {}
- at end
-
- at interface Foo : NSObject {
- id bar;
-}
- at property (strong) id bar;
--(void)test:(id)obj;
- at end
-
- at implementation Foo
-
- at synthesize bar;
-
--(void)test:(id)obj {
- id x = self.bar;
- self.bar = obj;
- // do stuff with x;
-
- IhaveSideEffect();
-
- x = 0;
-
- @try {
- } @finally {
- x = nil;
- }
-}
-
- at end
-
-void func(Foo *p) {
-}
-
- at interface Baz {
- id <NSObject> _foo;
-}
- at end
-
- at implementation Baz
- at end
-
-void block_test(Foo *p) {
- id (^B)(void) = ^(void) {
- if (p) {
- id (^IB)(void) = ^(void) {
- id bar = p;
- return bar;
- };
- IB();
- }
- return p;
- };
-}
-
-#define RELEASE_MACRO(x) [x release]
-#define RELEASE_MACRO2(x) RELEASE_MACRO(x)
-
-void test2(id p) {
-}
-
- at implementation Foo2
-
-static id internal_var = 0;
-
-+ (void)setIt:(id)newone {
- if (internal_var != newone) {
- internal_var = newone;
- }
-}
- at end
diff --git a/clang/test/ARCMT/remap-applying.c b/clang/test/ARCMT/remap-applying.c
deleted file mode 100644
index dee2e391d5bd5b..00000000000000
--- a/clang/test/ARCMT/remap-applying.c
+++ /dev/null
@@ -1,4 +0,0 @@
-a bc
-
-// RUN: echo "[{\"file\": \"%/s\", \"offset\": 1, \"remove\": 2, }]" > %t.remap
-// RUN: c-arcmt-test %t.remap | arcmt-test -verify-transformed-files %s.result
diff --git a/clang/test/ARCMT/remap-applying.c.result b/clang/test/ARCMT/remap-applying.c.result
deleted file mode 100644
index 514e9c264915d9..00000000000000
--- a/clang/test/ARCMT/remap-applying.c.result
+++ /dev/null
@@ -1,4 +0,0 @@
-ac
-
-// RUN: echo "[{\"file\": \"%/s\", \"offset\": 1, \"remove\": 2, }]" > %t.remap
-// RUN: c-arcmt-test %t.remap | arcmt-test -verify-transformed-files %s.result
diff --git a/clang/test/ARCMT/remove-dealloc-method.m b/clang/test/ARCMT/remove-dealloc-method.m
deleted file mode 100644
index 8e39fc874c950c..00000000000000
--- a/clang/test/ARCMT/remove-dealloc-method.m
+++ /dev/null
@@ -1,26 +0,0 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result
-// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s > %t
-// RUN: diff %t %s.result
-
-#define nil ((void*) 0)
-
- at interface Foo
- at property (retain) id x;
- at property (retain) id y;
- at property (retain) id w;
- at property (retain) id z;
- at end
-
- at implementation Foo
- at synthesize x;
- at synthesize y;
- at synthesize w;
- at synthesize z;
-
-- (void) dealloc {
- self.x = 0;
- [self setY:nil];
- w = nil;
- self.z = nil;
-}
- at end
diff --git a/clang/test/ARCMT/remove-dealloc-method.m.result b/clang/test/ARCMT/remove-dealloc-method.m.result
deleted file mode 100644
index 47e31f9d249aed..00000000000000
--- a/clang/test/ARCMT/remove-dealloc-method.m.result
+++ /dev/null
@@ -1,20 +0,0 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result
-// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s > %t
-// RUN: diff %t %s.result
-
-#define nil ((void*) 0)
-
- at interface Foo
- at property (strong) id x;
- at property (strong) id y;
- at property (strong) id w;
- at property (strong) id z;
- at end
-
- at implementation Foo
- at synthesize x;
- at synthesize y;
- at synthesize w;
- at synthesize z;
-
- at end
diff --git a/clang/test/ARCMT/remove-dealloc-zerouts.m b/clang/test/ARCMT/remove-dealloc-zerouts.m
deleted file mode 100644
index 4176ec580c3e58..00000000000000
--- a/clang/test/ARCMT/remove-dealloc-zerouts.m
+++ /dev/null
@@ -1,44 +0,0 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result
-// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s > %t
-// RUN: diff %t %s.result
-
- at interface Foo
- at property (retain) id x;
- at property (retain) id y;
- at property (retain) id w;
- at property (retain) id z;
- at property (strong) id q;
- at end
-
- at implementation Foo
- at synthesize x;
- at synthesize y;
- at synthesize w;
- at synthesize q;
- at dynamic z;
-
-- (void) dealloc {
- self.x = self.y = self.w = 0;
- self.x = 0, w = 0, y = 0;
- [self setY:0];
- w = 0;
- q = 0;
- self.z = 0;
-}
- at end
-
- at interface Bar
- at property (retain) Foo *a;
-- (void) setA:(Foo*) val;
-- (id) a;
- at end
-
- at implementation Bar
-- (void) dealloc {
- [self setA:0]; // This is user-defined setter overriding synthesize, don't touch it.
- self.a.x = 0; // every dealloc must zero out its own ivar. This patter is not recognized.
-}
- at synthesize a;
-- (void) setA:(Foo*) val { }
-- (id) a {return 0;}
- at end
diff --git a/clang/test/ARCMT/remove-dealloc-zerouts.m.result b/clang/test/ARCMT/remove-dealloc-zerouts.m.result
deleted file mode 100644
index 9ae831abacf25c..00000000000000
--- a/clang/test/ARCMT/remove-dealloc-zerouts.m.result
+++ /dev/null
@@ -1,39 +0,0 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result
-// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s > %t
-// RUN: diff %t %s.result
-
- at interface Foo
- at property (strong) id x;
- at property (strong) id y;
- at property (strong) id w;
- at property (strong) id z;
- at property (strong) id q;
- at end
-
- at implementation Foo
- at synthesize x;
- at synthesize y;
- at synthesize w;
- at synthesize q;
- at dynamic z;
-
-- (void) dealloc {
- self.z = 0;
-}
- at end
-
- at interface Bar
- at property (strong) Foo *a;
-- (void) setA:(Foo*) val;
-- (id) a;
- at end
-
- at implementation Bar
-- (void) dealloc {
- [self setA:0]; // This is user-defined setter overriding synthesize, don't touch it.
- self.a.x = 0; // every dealloc must zero out its own ivar. This patter is not recognized.
-}
- at synthesize a;
-- (void) setA:(Foo*) val { }
-- (id) a {return 0;}
- at end
diff --git a/clang/test/ARCMT/remove-statements.m b/clang/test/ARCMT/remove-statements.m
deleted file mode 100644
index 286a8e715e0d3f..00000000000000
--- a/clang/test/ARCMT/remove-statements.m
+++ /dev/null
@@ -1,45 +0,0 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result
-// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s > %t
-// RUN: diff %t %s.result
-
-#include "Common.h"
-
- at interface myController : NSObject
--(id)test:(id)x;
- at end
-
-#define MY_MACRO1(x)
-#define MY_MACRO2(x) (void)x
-
- at implementation myController
--(id) test:(id) x {
- [[x retain] release];
- return [[x retain] autorelease];
-}
-
--(void)dealloc
-{
- id array, array_already_empty;
- for (id element in array_already_empty) {
- }
-
- [array release];
- ;
-
- int b, b_array_already_empty;
- if (b)
- [array release];
- if (b_array_already_empty) ;
-
- if (b) {
- [array release];
- }
- if (b_array_already_empty) {
- }
-
- if (b)
- MY_MACRO1(array);
- if (b)
- MY_MACRO2(array);
-}
- at end
diff --git a/clang/test/ARCMT/remove-statements.m.result b/clang/test/ARCMT/remove-statements.m.result
deleted file mode 100644
index 6a4ea08b8c95b4..00000000000000
--- a/clang/test/ARCMT/remove-statements.m.result
+++ /dev/null
@@ -1,38 +0,0 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result
-// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s > %t
-// RUN: diff %t %s.result
-
-#include "Common.h"
-
- at interface myController : NSObject
--(id)test:(id)x;
- at end
-
-#define MY_MACRO1(x)
-#define MY_MACRO2(x) (void)x
-
- at implementation myController
--(id) test:(id) x {
- return x;
-}
-
--(void)dealloc
-{
- id array, array_already_empty;
- for (id element in array_already_empty) {
- }
-
- ;
-
- int b, b_array_already_empty;
- if (b_array_already_empty) ;
-
- if (b_array_already_empty) {
- }
-
- if (b)
- MY_MACRO1(array);
- if (b)
- MY_MACRO2(array);
-}
- at end
diff --git a/clang/test/ARCMT/retains.m b/clang/test/ARCMT/retains.m
deleted file mode 100644
index 43a94fc16cecf2..00000000000000
--- a/clang/test/ARCMT/retains.m
+++ /dev/null
@@ -1,71 +0,0 @@
-// RUN: %clang_cc1 -fblocks -fsyntax-only -fobjc-arc -x objective-c %s.result
-// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fblocks -fsyntax-only -x objective-c %s > %t
-// RUN: diff %t %s.result
-
-#include "Common.h"
-
-id IhaveSideEffect(void);
-
- at interface Foo : NSObject {
- id bar;
-}
- at property (retain) id bar;
--(id)test:(id)obj;
--(id)something;
- at end
-
-#define Something_Macro(key, comment) \
- [[Foo new] something]
-
- at implementation Foo
-
- at synthesize bar;
-
--(id)something {}
-
--(id)test:(id)obj {
- id x = self.bar;
- [x retain];
- self.bar = obj;
- if (obj)
- [obj retain];
-
- [Something_Macro(@"foo", "@bar") retain];
-
- [IhaveSideEffect() retain];
-
- [[self something] retain];
-
- [[self retain] something];
-
- [[IhaveSideEffect() retain] release];
- [[x retain] release];
- // do stuff with x;
- [x release];
- return [self retain];
-}
-
-- (id)test1 {
- id x=0;
- ([x retain]);
- return ((([x retain])));
-}
- at end
-
-id foo (Foo *p) {
- p = [p retain];
- return ([p retain]);
-}
-
-void block_tests(Foo *p) {
- id (^B)(void) = ^(void) {
- if (p) {
- id (^IB)(void) = ^(void) {
- id bar = [p retain];
- return bar;
- };
- IB();
- }
- return [p retain];
- };
-}
diff --git a/clang/test/ARCMT/retains.m.result b/clang/test/ARCMT/retains.m.result
deleted file mode 100644
index 4e720d6bb4c112..00000000000000
--- a/clang/test/ARCMT/retains.m.result
+++ /dev/null
@@ -1,65 +0,0 @@
-// RUN: %clang_cc1 -fblocks -fsyntax-only -fobjc-arc -x objective-c %s.result
-// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fblocks -fsyntax-only -x objective-c %s > %t
-// RUN: diff %t %s.result
-
-#include "Common.h"
-
-id IhaveSideEffect(void);
-
- at interface Foo : NSObject {
- id bar;
-}
- at property (strong) id bar;
--(id)test:(id)obj;
--(id)something;
- at end
-
-#define Something_Macro(key, comment) \
- [[Foo new] something]
-
- at implementation Foo
-
- at synthesize bar;
-
--(id)something {}
-
--(id)test:(id)obj {
- id x = self.bar;
- self.bar = obj;
-
- Something_Macro(@"foo", "@bar");
-
- IhaveSideEffect();
-
- [self something];
-
- [self something];
-
- IhaveSideEffect();
- // do stuff with x;
- return self;
-}
-
-- (id)test1 {
- id x=0;
- return (((x)));
-}
- at end
-
-id foo (Foo *p) {
- p = p;
- return (p);
-}
-
-void block_tests(Foo *p) {
- id (^B)(void) = ^(void) {
- if (p) {
- id (^IB)(void) = ^(void) {
- id bar = p;
- return bar;
- };
- IB();
- }
- return p;
- };
-}
diff --git a/clang/test/ARCMT/rewrite-block-var.m b/clang/test/ARCMT/rewrite-block-var.m
deleted file mode 100644
index eb3c5b65359718..00000000000000
--- a/clang/test/ARCMT/rewrite-block-var.m
+++ /dev/null
@@ -1,45 +0,0 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fblocks -fsyntax-only -fobjc-arc -x objective-c -fobjc-runtime-has-weak %s.result
-// RUN: arcmt-test --args -triple x86_64-apple-macosx10.7 -fblocks -fsyntax-only %s > %t
-// RUN: diff %t %s.result
-
-#include "Common.h"
-
- at interface Foo : NSObject
--(Foo *)something;
- at end
-
-void bar(void (^block)(void));
-
-void test1(Foo *p) {
- __block Foo *x = p; // __block used just to break cycle.
- bar(^{
- [x something];
- });
-}
-
-void test2(Foo *p) {
- __block Foo *x; // __block used as output variable.
- bar(^{
- x = [p something];
- });
-}
-
-void test3(Foo *p) {
- __block Foo *x; // __block used as output variable.
- bar(^{
- [x something];
- });
- bar(^{
- x = 0;
- });
-}
-
-void test4(Foo *p) {
- __block Foo *x = p; // __block used just to break cycle.
- bar(^{
- [x something];
- });
- bar(^{
- [x something];
- });
-}
diff --git a/clang/test/ARCMT/rewrite-block-var.m.result b/clang/test/ARCMT/rewrite-block-var.m.result
deleted file mode 100644
index cf5718fbd7f5de..00000000000000
--- a/clang/test/ARCMT/rewrite-block-var.m.result
+++ /dev/null
@@ -1,45 +0,0 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fblocks -fsyntax-only -fobjc-arc -x objective-c -fobjc-runtime-has-weak %s.result
-// RUN: arcmt-test --args -triple x86_64-apple-macosx10.7 -fblocks -fsyntax-only %s > %t
-// RUN: diff %t %s.result
-
-#include "Common.h"
-
- at interface Foo : NSObject
--(Foo *)something;
- at end
-
-void bar(void (^block)(void));
-
-void test1(Foo *p) {
- __weak Foo *x = p; // __block used just to break cycle.
- bar(^{
- [x something];
- });
-}
-
-void test2(Foo *p) {
- __block Foo *x; // __block used as output variable.
- bar(^{
- x = [p something];
- });
-}
-
-void test3(Foo *p) {
- __block Foo *x; // __block used as output variable.
- bar(^{
- [x something];
- });
- bar(^{
- x = 0;
- });
-}
-
-void test4(Foo *p) {
- __weak Foo *x = p; // __block used just to break cycle.
- bar(^{
- [x something];
- });
- bar(^{
- [x something];
- });
-}
diff --git a/clang/test/ARCMT/safe-arc-assign.m b/clang/test/ARCMT/safe-arc-assign.m
deleted file mode 100644
index 4a0a575794e162..00000000000000
--- a/clang/test/ARCMT/safe-arc-assign.m
+++ /dev/null
@@ -1,14 +0,0 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result
-// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s > %t
-// RUN: diff %t %s.result
-
-void test12(id collection) {
- for (id x in collection) {
- x = 0;
- x = 0;
- }
-
- for (__strong id x in collection) {
- x = 0;
- }
-}
diff --git a/clang/test/ARCMT/safe-arc-assign.m.result b/clang/test/ARCMT/safe-arc-assign.m.result
deleted file mode 100644
index c25955ea7d1c90..00000000000000
--- a/clang/test/ARCMT/safe-arc-assign.m.result
+++ /dev/null
@@ -1,14 +0,0 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result
-// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s > %t
-// RUN: diff %t %s.result
-
-void test12(id collection) {
- for (__strong id x in collection) {
- x = 0;
- x = 0;
- }
-
- for (__strong id x in collection) {
- x = 0;
- }
-}
diff --git a/clang/test/ARCMT/verify.m b/clang/test/ARCMT/verify.m
deleted file mode 100644
index 7d245fe80575e5..00000000000000
--- a/clang/test/ARCMT/verify.m
+++ /dev/null
@@ -1,17 +0,0 @@
-// RUN: %clang_cc1 -arcmt-action=check -verify %s
-// RUN: not %clang_cc1 -arcmt-action=check -verify %t.invalid 2>&1 | FileCheck %s
-
-#if 0
-// expected-error {{should be ignored}}
-#endif
-
-#error should not be ignored
-// expected-error at -1 {{should not be ignored}}
-
-#error
-// expected-error at -1 {{}}
-
-// CHECK: error: no expected directives found: consider use of 'expected-no-diagnostics'
-// CHECK-NEXT: error: 'expected-error' diagnostics seen but not expected:
-// CHECK-NEXT: (frontend): error reading '{{.*}}verify.m.tmp.invalid'
-// CHECK-NEXT: 2 errors generated.
diff --git a/clang/test/ARCMT/with-arc-mode-modify.m b/clang/test/ARCMT/with-arc-mode-modify.m
deleted file mode 100644
index beff6784bbbb07..00000000000000
--- a/clang/test/ARCMT/with-arc-mode-modify.m
+++ /dev/null
@@ -1,13 +0,0 @@
-// RUN: %clang_cc1 -fsyntax-only -fobjc-arc -x objective-c %s.result
-// RUN: cat %s > %t
-// RUN: %clang_cc1 -arcmt-action=modify -fsyntax-only -fobjc-arc -x objective-c %t
-// RUN: diff %t %s.result
-// RUN: rm %t
-
- at protocol NSObject
-- (oneway void)release;
- at end
-
-void test1(id p) {
- [p release];
-}
diff --git a/clang/test/ARCMT/with-arc-mode-modify.m.result b/clang/test/ARCMT/with-arc-mode-modify.m.result
deleted file mode 100644
index 685226db865415..00000000000000
--- a/clang/test/ARCMT/with-arc-mode-modify.m.result
+++ /dev/null
@@ -1,12 +0,0 @@
-// RUN: %clang_cc1 -fsyntax-only -fobjc-arc -x objective-c %s.result
-// RUN: cat %s > %t
-// RUN: %clang_cc1 -arcmt-action=modify -fsyntax-only -fobjc-arc -x objective-c %t
-// RUN: diff %t %s.result
-// RUN: rm %t
-
- at protocol NSObject
-- (oneway void)release;
- at end
-
-void test1(id p) {
-}
>From 0b6ad885bed45fbbd7adb126e2fd6efa7dc9ccc2 Mon Sep 17 00:00:00 2001
From: Sirraide <aeternalmail at gmail.com>
Date: Fri, 17 Jan 2025 03:49:16 +0100
Subject: [PATCH 2/7] Remove remaining references to ARCMigrate
---
clang/CMakeLists.txt | 9 -
clang/cmake/caches/Android.cmake | 1 -
clang/cmake/caches/Fuchsia-stage2.cmake | 1 -
clang/cmake/caches/Fuchsia.cmake | 1 -
clang/docs/ReleaseNotes.rst | 2 +
.../clang/Basic/DiagnosticCommonKinds.td | 10 -
clang/include/clang/Config/config.h.cmake | 1 -
clang/include/clang/Driver/Action.h | 12 -
clang/include/clang/Driver/Options.td | 108 -----
.../include/clang/Frontend/FrontendOptions.h | 89 +----
clang/lib/CMakeLists.txt | 3 -
clang/lib/Driver/Action.cpp | 9 +-
clang/lib/Driver/Driver.cpp | 6 +-
clang/lib/Driver/ToolChain.cpp | 1 -
clang/lib/Driver/ToolChains/Clang.cpp | 76 ----
clang/lib/Driver/ToolChains/Darwin.cpp | 14 -
clang/lib/Frontend/CompilerInvocation.cpp | 8 +-
clang/lib/FrontendTool/CMakeLists.txt | 6 -
.../ExecuteCompilerInvocation.cpp | 30 --
.../DependencyScanning/ModuleDepCollector.cpp | 3 -
clang/test/CMakeLists.txt | 8 -
clang/test/ClangScanDeps/strip-input-args.m | 9 +-
.../test/Driver/objc-sdk-migration-options.m | 8 -
clang/test/Misc/warning-flags.c | 4 +-
clang/test/lit.site.cfg.py.in | 1 -
clang/tools/CMakeLists.txt | 5 -
clang/tools/arcmt-test/CMakeLists.txt | 16 -
clang/tools/arcmt-test/arcmt-test.cpp | 376 ------------------
clang/tools/c-arcmt-test/CMakeLists.txt | 19 -
clang/tools/c-arcmt-test/c-arcmt-test.c | 138 -------
clang/tools/libclang/ARCMigrate.cpp | 138 -------
clang/tools/libclang/CMakeLists.txt | 8 -
clang/tools/libclang/libclang.map | 5 -
clang/unittests/Basic/DiagnosticTest.cpp | 4 +-
clang/utils/analyzer/entrypoint.py | 1 -
35 files changed, 21 insertions(+), 1109 deletions(-)
delete mode 100644 clang/test/Driver/objc-sdk-migration-options.m
delete mode 100644 clang/tools/arcmt-test/CMakeLists.txt
delete mode 100644 clang/tools/arcmt-test/arcmt-test.cpp
delete mode 100644 clang/tools/c-arcmt-test/CMakeLists.txt
delete mode 100644 clang/tools/c-arcmt-test/c-arcmt-test.c
delete mode 100644 clang/tools/libclang/ARCMigrate.cpp
diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index 27e8095534a65c..7050746e3a0380 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -432,20 +432,11 @@ if(NOT LLVM_STATIC_LINK_CXX_STDLIB)
set(HAVE_CLANG_REPL_SUPPORT ON)
endif()
-option(CLANG_ENABLE_ARCMT "Build ARCMT." ON)
option(CLANG_ENABLE_STATIC_ANALYZER
"Include static analyzer in clang binary." ON)
option(CLANG_ENABLE_PROTO_FUZZER "Build Clang protobuf fuzzer." OFF)
-if(NOT CLANG_ENABLE_STATIC_ANALYZER AND CLANG_ENABLE_ARCMT)
- message(FATAL_ERROR "Cannot disable static analyzer while enabling ARCMT or Z3")
-endif()
-
-if(CLANG_ENABLE_ARCMT)
- set(CLANG_ENABLE_OBJC_REWRITER ON)
-endif()
-
# This option is a stop-gap, we should commit to removing this as
# soon as possible. See discussion:
# https://discourse.llvm.org/t/rationale-for-removing-versioned-libclang-middle-ground-to-keep-it-behind-option/
diff --git a/clang/cmake/caches/Android.cmake b/clang/cmake/caches/Android.cmake
index d5ca6b50d4ada7..c89e31f67cc9b1 100644
--- a/clang/cmake/caches/Android.cmake
+++ b/clang/cmake/caches/Android.cmake
@@ -2,7 +2,6 @@
set(LLVM_TARGETS_TO_BUILD X86 CACHE STRING "")
-set(CLANG_ENABLE_ARCMT OFF CACHE BOOL "")
set(CLANG_ENABLE_STATIC_ANALYZER OFF CACHE BOOL "")
set(CLANG_TIDY_ENABLE_STATIC_ANALYZER OFF CACHE BOOL "")
set(CLANG_VENDOR Android CACHE STRING "")
diff --git a/clang/cmake/caches/Fuchsia-stage2.cmake b/clang/cmake/caches/Fuchsia-stage2.cmake
index 784a883a3bf916..3db19c36acc581 100644
--- a/clang/cmake/caches/Fuchsia-stage2.cmake
+++ b/clang/cmake/caches/Fuchsia-stage2.cmake
@@ -44,7 +44,6 @@ set(CLANG_DEFAULT_LINKER lld CACHE STRING "")
set(CLANG_DEFAULT_OBJCOPY llvm-objcopy CACHE STRING "")
set(CLANG_DEFAULT_RTLIB compiler-rt CACHE STRING "")
set(CLANG_DEFAULT_UNWINDLIB libunwind CACHE STRING "")
-set(CLANG_ENABLE_ARCMT OFF CACHE BOOL "")
set(CLANG_ENABLE_STATIC_ANALYZER ON CACHE BOOL "")
set(CLANG_PLUGIN_SUPPORT OFF CACHE BOOL "")
diff --git a/clang/cmake/caches/Fuchsia.cmake b/clang/cmake/caches/Fuchsia.cmake
index 07637cd0ed08f0..83336589da305d 100644
--- a/clang/cmake/caches/Fuchsia.cmake
+++ b/clang/cmake/caches/Fuchsia.cmake
@@ -84,7 +84,6 @@ set(CLANG_DEFAULT_LINKER lld CACHE STRING "")
set(CLANG_DEFAULT_OBJCOPY llvm-objcopy CACHE STRING "")
set(CLANG_DEFAULT_RTLIB compiler-rt CACHE STRING "")
set(CLANG_DEFAULT_UNWINDLIB libunwind CACHE STRING "")
-set(CLANG_ENABLE_ARCMT OFF CACHE BOOL "")
set(CLANG_ENABLE_STATIC_ANALYZER OFF CACHE BOOL "")
set(CLANG_PLUGIN_SUPPORT OFF CACHE BOOL "")
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 3f58e64cf0ccbc..c168606af609ed 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -58,6 +58,8 @@ code bases.
containing strict-aliasing violations. The new default behavior can be
disabled using ``-fno-pointer-tbaa``.
+- The Objective-C ARC migrator (ARCMigrate) has been removed.
+
C/C++ Language Potentially Breaking Changes
-------------------------------------------
diff --git a/clang/include/clang/Basic/DiagnosticCommonKinds.td b/clang/include/clang/Basic/DiagnosticCommonKinds.td
index f4a155bb00bb37..f26c906b46447a 100644
--- a/clang/include/clang/Basic/DiagnosticCommonKinds.td
+++ b/clang/include/clang/Basic/DiagnosticCommonKinds.td
@@ -402,16 +402,6 @@ def note_file_misc_sloc_usage : Note<
def err_module_format_unhandled : Error<
"no handler registered for module format '%0'">, DefaultFatal;
-// TransformActions
-// TODO: Use a custom category name to distinguish rewriter errors.
-def err_mt_message : Error<"[rewriter] %0">, SuppressInSystemHeader;
-def warn_mt_message : Warning<"[rewriter] %0">;
-def note_mt_message : Note<"[rewriter] %0">;
-
-// ARCMigrate
-def warn_arcmt_nsalloc_realloc : Warning<"[rewriter] call returns pointer to GC managed memory; it will become unmanaged in ARC">;
-def err_arcmt_nsinvocation_ownership : Error<"NSInvocation's %0 is not safe to be used with an object with ownership other than __unsafe_unretained">;
-
// API notes
def err_apinotes_message : Error<"%0">;
def warn_apinotes_message : Warning<"%0">, InGroup<DiagGroup<"apinotes">>;
diff --git a/clang/include/clang/Config/config.h.cmake b/clang/include/clang/Config/config.h.cmake
index 27ed69e21562bf..00c352b458c34d 100644
--- a/clang/include/clang/Config/config.h.cmake
+++ b/clang/include/clang/Config/config.h.cmake
@@ -76,7 +76,6 @@
#cmakedefine01 PPC_LINUX_DEFAULT_IEEELONGDOUBLE
/* Enable each functionality of modules */
-#cmakedefine01 CLANG_ENABLE_ARCMT
#cmakedefine01 CLANG_ENABLE_OBJC_REWRITER
#cmakedefine01 CLANG_ENABLE_STATIC_ANALYZER
diff --git a/clang/include/clang/Driver/Action.h b/clang/include/clang/Driver/Action.h
index 04fa8b01b418f8..bb9444d2e9ccdc 100644
--- a/clang/include/clang/Driver/Action.h
+++ b/clang/include/clang/Driver/Action.h
@@ -60,7 +60,6 @@ class Action {
PrecompileJobClass,
ExtractAPIJobClass,
AnalyzeJobClass,
- MigrateJobClass,
CompileJobClass,
BackendJobClass,
AssembleJobClass,
@@ -459,17 +458,6 @@ class AnalyzeJobAction : public JobAction {
}
};
-class MigrateJobAction : public JobAction {
- void anchor() override;
-
-public:
- MigrateJobAction(Action *Input, types::ID OutputType);
-
- static bool classof(const Action *A) {
- return A->getKind() == MigrateJobClass;
- }
-};
-
class CompileJobAction : public JobAction {
void anchor() override;
diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index a89a4e8f8ec985..ee9e0152e8317f 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -692,20 +692,6 @@ def ccc_print_phases : Flag<["-"], "ccc-print-phases">,
def ccc_print_bindings : Flag<["-"], "ccc-print-bindings">, InternalDebugOpt,
HelpText<"Show bindings of tools to actions">;
-def ccc_arcmt_check : Flag<["-"], "ccc-arcmt-check">, InternalDriverOpt,
- HelpText<"Check for ARC migration issues that need manual handling">;
-def ccc_arcmt_modify : Flag<["-"], "ccc-arcmt-modify">, InternalDriverOpt,
- HelpText<"Apply modifications to files to conform to ARC">;
-def ccc_arcmt_migrate : Separate<["-"], "ccc-arcmt-migrate">, InternalDriverOpt,
- HelpText<"Apply modifications and produces temporary files that conform to ARC">;
-def arcmt_migrate_report_output : Separate<["-"], "arcmt-migrate-report-output">,
- HelpText<"Output path for the plist report">,
- Visibility<[ClangOption, CC1Option]>,
- MarshallingInfoString<FrontendOpts<"ARCMTMigrateReportOut">>;
-def arcmt_migrate_emit_arc_errors : Flag<["-"], "arcmt-migrate-emit-errors">,
- HelpText<"Emit ARC errors even if the migrator can fix them">,
- Visibility<[ClangOption, CC1Option]>,
- MarshallingInfoFlag<FrontendOpts<"ARCMTMigrateEmitARCErrors">>;
def gen_reproducer_eq: Joined<["-"], "gen-reproducer=">,
Flags<[NoArgumentUnused]>, Visibility<[ClangOption, CLOption, DXCOption]>,
HelpText<"Emit reproducer on (option: off, crash (default), error, always)">;
@@ -721,87 +707,6 @@ def no_round_trip_args : Flag<["-"], "no-round-trip-args">,
Visibility<[CC1Option]>,
HelpText<"Disable command line arguments round-trip.">;
-def _migrate : Flag<["--"], "migrate">, Flags<[NoXarchOption]>,
- HelpText<"Run the migrator">;
-def ccc_objcmt_migrate : Separate<["-"], "ccc-objcmt-migrate">,
- InternalDriverOpt,
- HelpText<"Apply modifications and produces temporary files to migrate to "
- "modern ObjC syntax">;
-
-def objcmt_migrate_literals : Flag<["-"], "objcmt-migrate-literals">,
- Visibility<[ClangOption, CC1Option]>,
- HelpText<"Enable migration to modern ObjC literals">,
- MarshallingInfoBitfieldFlag<FrontendOpts<"ObjCMTAction">, "FrontendOptions::ObjCMT_Literals">;
-def objcmt_migrate_subscripting : Flag<["-"], "objcmt-migrate-subscripting">,
- Visibility<[ClangOption, CC1Option]>,
- HelpText<"Enable migration to modern ObjC subscripting">,
- MarshallingInfoBitfieldFlag<FrontendOpts<"ObjCMTAction">, "FrontendOptions::ObjCMT_Subscripting">;
-def objcmt_migrate_property : Flag<["-"], "objcmt-migrate-property">,
- Visibility<[ClangOption, CC1Option]>,
- HelpText<"Enable migration to modern ObjC property">,
- MarshallingInfoBitfieldFlag<FrontendOpts<"ObjCMTAction">, "FrontendOptions::ObjCMT_Property">;
-def objcmt_migrate_all : Flag<["-"], "objcmt-migrate-all">,
- Visibility<[ClangOption, CC1Option]>,
- HelpText<"Enable migration to modern ObjC">,
- MarshallingInfoBitfieldFlag<FrontendOpts<"ObjCMTAction">, "FrontendOptions::ObjCMT_MigrateDecls">;
-def objcmt_migrate_readonly_property : Flag<["-"], "objcmt-migrate-readonly-property">,
- Visibility<[ClangOption, CC1Option]>,
- HelpText<"Enable migration to modern ObjC readonly property">,
- MarshallingInfoBitfieldFlag<FrontendOpts<"ObjCMTAction">, "FrontendOptions::ObjCMT_ReadonlyProperty">;
-def objcmt_migrate_readwrite_property : Flag<["-"], "objcmt-migrate-readwrite-property">,
- Visibility<[ClangOption, CC1Option]>,
- HelpText<"Enable migration to modern ObjC readwrite property">,
- MarshallingInfoBitfieldFlag<FrontendOpts<"ObjCMTAction">, "FrontendOptions::ObjCMT_ReadwriteProperty">;
-def objcmt_migrate_property_dot_syntax : Flag<["-"], "objcmt-migrate-property-dot-syntax">,
- Visibility<[ClangOption, CC1Option]>,
- HelpText<"Enable migration of setter/getter messages to property-dot syntax">,
- MarshallingInfoBitfieldFlag<FrontendOpts<"ObjCMTAction">, "FrontendOptions::ObjCMT_PropertyDotSyntax">;
-def objcmt_migrate_annotation : Flag<["-"], "objcmt-migrate-annotation">,
- Visibility<[ClangOption, CC1Option]>,
- HelpText<"Enable migration to property and method annotations">,
- MarshallingInfoBitfieldFlag<FrontendOpts<"ObjCMTAction">, "FrontendOptions::ObjCMT_Annotation">;
-def objcmt_migrate_instancetype : Flag<["-"], "objcmt-migrate-instancetype">,
- Visibility<[ClangOption, CC1Option]>,
- HelpText<"Enable migration to infer instancetype for method result type">,
- MarshallingInfoBitfieldFlag<FrontendOpts<"ObjCMTAction">, "FrontendOptions::ObjCMT_Instancetype">;
-def objcmt_migrate_nsmacros : Flag<["-"], "objcmt-migrate-ns-macros">,
- Visibility<[ClangOption, CC1Option]>,
- HelpText<"Enable migration to NS_ENUM/NS_OPTIONS macros">,
- MarshallingInfoBitfieldFlag<FrontendOpts<"ObjCMTAction">, "FrontendOptions::ObjCMT_NsMacros">;
-def objcmt_migrate_protocol_conformance : Flag<["-"], "objcmt-migrate-protocol-conformance">,
- Visibility<[ClangOption, CC1Option]>,
- HelpText<"Enable migration to add protocol conformance on classes">,
- MarshallingInfoBitfieldFlag<FrontendOpts<"ObjCMTAction">, "FrontendOptions::ObjCMT_ProtocolConformance">;
-def objcmt_atomic_property : Flag<["-"], "objcmt-atomic-property">,
- Visibility<[ClangOption, CC1Option]>,
- HelpText<"Make migration to 'atomic' properties">,
- MarshallingInfoBitfieldFlag<FrontendOpts<"ObjCMTAction">, "FrontendOptions::ObjCMT_AtomicProperty">;
-def objcmt_returns_innerpointer_property : Flag<["-"], "objcmt-returns-innerpointer-property">,
- Visibility<[ClangOption, CC1Option]>,
- HelpText<"Enable migration to annotate property with NS_RETURNS_INNER_POINTER">,
- MarshallingInfoBitfieldFlag<FrontendOpts<"ObjCMTAction">, "FrontendOptions::ObjCMT_ReturnsInnerPointerProperty">;
-def objcmt_ns_nonatomic_iosonly: Flag<["-"], "objcmt-ns-nonatomic-iosonly">,
- Visibility<[ClangOption, CC1Option]>,
- HelpText<"Enable migration to use NS_NONATOMIC_IOSONLY macro for setting property's 'atomic' attribute">,
- MarshallingInfoBitfieldFlag<FrontendOpts<"ObjCMTAction">, "FrontendOptions::ObjCMT_NsAtomicIOSOnlyProperty">;
-def objcmt_migrate_designated_init : Flag<["-"], "objcmt-migrate-designated-init">,
- Visibility<[ClangOption, CC1Option]>,
- HelpText<"Enable migration to infer NS_DESIGNATED_INITIALIZER for initializer methods">,
- MarshallingInfoBitfieldFlag<FrontendOpts<"ObjCMTAction">, "FrontendOptions::ObjCMT_DesignatedInitializer">;
-
-def objcmt_allowlist_dir_path: Joined<["-"], "objcmt-allowlist-dir-path=">,
- Visibility<[ClangOption, CC1Option]>,
- HelpText<"Only modify files with a filename contained in the provided directory path">,
- MarshallingInfoString<FrontendOpts<"ObjCMTAllowListPath">>;
-def : Joined<["-"], "objcmt-whitelist-dir-path=">,
- Visibility<[ClangOption, CC1Option]>,
- HelpText<"Alias for -objcmt-allowlist-dir-path">,
- Alias<objcmt_allowlist_dir_path>;
-// The misspelt "white-list" [sic] alias is due for removal.
-def : Joined<["-"], "objcmt-white-list-dir-path=">,
- Visibility<[ClangOption, CC1Option]>,
- Alias<objcmt_allowlist_dir_path>;
-
// Make sure all other -ccc- options are rejected.
def ccc_ : Joined<["-"], "ccc-">, Group<internal_Group>, Flags<[Unsupported]>;
@@ -7899,8 +7804,6 @@ def rewrite_test : Flag<["-"], "rewrite-test">,
HelpText<"Rewriter playground">;
def rewrite_macros : Flag<["-"], "rewrite-macros">,
HelpText<"Expand macros without full preprocessing">;
-def migrate : Flag<["-"], "migrate">,
- HelpText<"Migrate source code">;
def compiler_options_dump : Flag<["-"], "compiler-options-dump">,
HelpText<"Dump the compiler configuration options">;
def print_dependency_directives_minimized_source : Flag<["-"],
@@ -7914,17 +7817,6 @@ defm emit_llvm_uselists : BoolOption<"", "emit-llvm-uselists",
NegFlag<SetFalse, [], [ClangOption], "Don't preserve">,
BothFlags<[], [ClangOption], " order of LLVM use-lists when serializing">>;
-def mt_migrate_directory : Separate<["-"], "mt-migrate-directory">,
- HelpText<"Directory for temporary files produced during ARC or ObjC migration">,
- MarshallingInfoString<FrontendOpts<"MTMigrateDir">>;
-
-def arcmt_action_EQ : Joined<["-"], "arcmt-action=">, Visibility<[CC1Option]>,
- HelpText<"The ARC migration action to take">,
- Values<"check,modify,migrate">,
- NormalizedValuesScope<"FrontendOptions">,
- NormalizedValues<["ARCMT_Check", "ARCMT_Modify", "ARCMT_Migrate"]>,
- MarshallingInfoEnum<FrontendOpts<"ARCMTAction">, "ARCMT_None">;
-
def print_stats : Flag<["-"], "print-stats">,
HelpText<"Print performance metrics and statistics">,
MarshallingInfoFlag<FrontendOpts<"ShowStats">>;
diff --git a/clang/include/clang/Frontend/FrontendOptions.h b/clang/include/clang/Frontend/FrontendOptions.h
index 8241925c984763..99b2d9a98ed1f4 100644
--- a/clang/include/clang/Frontend/FrontendOptions.h
+++ b/clang/include/clang/Frontend/FrontendOptions.h
@@ -141,9 +141,6 @@ enum ActionKind {
/// Dump template instantiations
TemplightDump,
- /// Run migrator.
- MigrateSource,
-
/// Just lex, no output.
RunPreprocessorOnly,
@@ -330,10 +327,6 @@ class FrontendOptions {
LLVM_PREFERRED_TYPE(bool)
unsigned FixToTemporaries : 1;
- /// Emit ARC errors even if the migrator can fix them.
- LLVM_PREFERRED_TYPE(bool)
- unsigned ARCMTMigrateEmitARCErrors : 1;
-
/// Skip over function bodies to speed up parsing in cases you do not need
/// them (e.g. with code completion).
LLVM_PREFERRED_TYPE(bool)
@@ -424,72 +417,6 @@ class FrontendOptions {
/// Specifies the output format of the AST.
ASTDumpOutputFormat ASTDumpFormat = ADOF_Default;
- enum {
- ARCMT_None,
- ARCMT_Check,
- ARCMT_Modify,
- ARCMT_Migrate
- } ARCMTAction = ARCMT_None;
-
- enum {
- ObjCMT_None = 0,
-
- /// Enable migration to modern ObjC literals.
- ObjCMT_Literals = 0x1,
-
- /// Enable migration to modern ObjC subscripting.
- ObjCMT_Subscripting = 0x2,
-
- /// Enable migration to modern ObjC readonly property.
- ObjCMT_ReadonlyProperty = 0x4,
-
- /// Enable migration to modern ObjC readwrite property.
- ObjCMT_ReadwriteProperty = 0x8,
-
- /// Enable migration to modern ObjC property.
- ObjCMT_Property = (ObjCMT_ReadonlyProperty | ObjCMT_ReadwriteProperty),
-
- /// Enable annotation of ObjCMethods of all kinds.
- ObjCMT_Annotation = 0x10,
-
- /// Enable migration of ObjC methods to 'instancetype'.
- ObjCMT_Instancetype = 0x20,
-
- /// Enable migration to NS_ENUM/NS_OPTIONS macros.
- ObjCMT_NsMacros = 0x40,
-
- /// Enable migration to add conforming protocols.
- ObjCMT_ProtocolConformance = 0x80,
-
- /// prefer 'atomic' property over 'nonatomic'.
- ObjCMT_AtomicProperty = 0x100,
-
- /// annotate property with NS_RETURNS_INNER_POINTER
- ObjCMT_ReturnsInnerPointerProperty = 0x200,
-
- /// use NS_NONATOMIC_IOSONLY for property 'atomic' attribute
- ObjCMT_NsAtomicIOSOnlyProperty = 0x400,
-
- /// Enable inferring NS_DESIGNATED_INITIALIZER for ObjC methods.
- ObjCMT_DesignatedInitializer = 0x800,
-
- /// Enable converting setter/getter expressions to property-dot syntx.
- ObjCMT_PropertyDotSyntax = 0x1000,
-
- ObjCMT_MigrateDecls = (ObjCMT_ReadonlyProperty | ObjCMT_ReadwriteProperty |
- ObjCMT_Annotation | ObjCMT_Instancetype |
- ObjCMT_NsMacros | ObjCMT_ProtocolConformance |
- ObjCMT_NsAtomicIOSOnlyProperty |
- ObjCMT_DesignatedInitializer),
- ObjCMT_MigrateAll = (ObjCMT_Literals | ObjCMT_Subscripting |
- ObjCMT_MigrateDecls | ObjCMT_PropertyDotSyntax)
- };
- unsigned ObjCMTAction = ObjCMT_None;
- std::string ObjCMTAllowListPath;
-
- std::string MTMigrateDir;
- std::string ARCMTMigrateReportOut;
-
/// The input kind, either specified via -x argument or deduced from the input
/// file name.
InputKind DashX;
@@ -596,14 +523,14 @@ class FrontendOptions {
: DisableFree(false), RelocatablePCH(false), ShowHelp(false),
ShowStats(false), AppendStats(false), ShowVersion(false),
FixWhatYouCan(false), FixOnlyWarnings(false), FixAndRecompile(false),
- FixToTemporaries(false), ARCMTMigrateEmitARCErrors(false),
- SkipFunctionBodies(false), UseGlobalModuleIndex(true),
- GenerateGlobalModuleIndex(true), ASTDumpDecls(false),
- ASTDumpLookups(false), BuildingImplicitModule(false),
- BuildingImplicitModuleUsesLock(true), ModulesEmbedAllFiles(false),
- IncludeTimestamps(true), UseTemporary(true),
- AllowPCMWithCompilerErrors(false), ModulesShareFileManager(true),
- EmitSymbolGraph(false), EmitExtensionSymbolGraphs(false),
+ FixToTemporaries(false), SkipFunctionBodies(false),
+ UseGlobalModuleIndex(true), GenerateGlobalModuleIndex(true),
+ ASTDumpDecls(false), ASTDumpLookups(false),
+ BuildingImplicitModule(false), BuildingImplicitModuleUsesLock(true),
+ ModulesEmbedAllFiles(false), IncludeTimestamps(true),
+ UseTemporary(true), AllowPCMWithCompilerErrors(false),
+ ModulesShareFileManager(true), EmitSymbolGraph(false),
+ EmitExtensionSymbolGraphs(false),
EmitSymbolGraphSymbolLabelsForTesting(false),
EmitPrettySymbolGraphs(false), GenReducedBMI(false),
UseClangIRPipeline(false), TimeTraceGranularity(500),
diff --git a/clang/lib/CMakeLists.txt b/clang/lib/CMakeLists.txt
index 14ba55360fe050..4f2218b583e414 100644
--- a/clang/lib/CMakeLists.txt
+++ b/clang/lib/CMakeLists.txt
@@ -12,9 +12,6 @@ add_subdirectory(Analysis)
add_subdirectory(Edit)
add_subdirectory(ExtractAPI)
add_subdirectory(Rewrite)
-if(CLANG_ENABLE_ARCMT)
- add_subdirectory(ARCMigrate)
-endif()
add_subdirectory(Driver)
add_subdirectory(Serialization)
add_subdirectory(Frontend)
diff --git a/clang/lib/Driver/Action.cpp b/clang/lib/Driver/Action.cpp
index 849bf6035ebd2e..77ce5db106d621 100644
--- a/clang/lib/Driver/Action.cpp
+++ b/clang/lib/Driver/Action.cpp
@@ -27,8 +27,8 @@ const char *Action::getClassName(ActionClass AC) {
case PrecompileJobClass: return "precompiler";
case ExtractAPIJobClass:
return "api-extractor";
- case AnalyzeJobClass: return "analyzer";
- case MigrateJobClass: return "migrator";
+ case AnalyzeJobClass:
+ return "analyzer";
case CompileJobClass: return "compiler";
case BackendJobClass: return "backend";
case AssembleJobClass: return "assembler";
@@ -367,11 +367,6 @@ void AnalyzeJobAction::anchor() {}
AnalyzeJobAction::AnalyzeJobAction(Action *Input, types::ID OutputType)
: JobAction(AnalyzeJobClass, Input, OutputType) {}
-void MigrateJobAction::anchor() {}
-
-MigrateJobAction::MigrateJobAction(Action *Input, types::ID OutputType)
- : JobAction(MigrateJobClass, Input, OutputType) {}
-
void CompileJobAction::anchor() {}
CompileJobAction::CompileJobAction(Action *Input, types::ID OutputType)
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 7de8341b8d2d61..231187c0371436 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -366,12 +366,12 @@ phases::ID Driver::getFinalPhase(const DerivedArgList &DAL,
// -{fsyntax-only,-analyze,emit-ast} only run up to the compiler.
} else if ((PhaseArg = DAL.getLastArg(options::OPT_fsyntax_only)) ||
(PhaseArg = DAL.getLastArg(options::OPT_print_supported_cpus)) ||
- (PhaseArg = DAL.getLastArg(options::OPT_print_enabled_extensions)) ||
+ (PhaseArg =
+ DAL.getLastArg(options::OPT_print_enabled_extensions)) ||
(PhaseArg = DAL.getLastArg(options::OPT_module_file_info)) ||
(PhaseArg = DAL.getLastArg(options::OPT_verify_pch)) ||
(PhaseArg = DAL.getLastArg(options::OPT_rewrite_objc)) ||
(PhaseArg = DAL.getLastArg(options::OPT_rewrite_legacy_objc)) ||
- (PhaseArg = DAL.getLastArg(options::OPT__migrate)) ||
(PhaseArg = DAL.getLastArg(options::OPT__analyze)) ||
(PhaseArg = DAL.getLastArg(options::OPT_emit_cir)) ||
(PhaseArg = DAL.getLastArg(options::OPT_emit_ast))) {
@@ -4856,8 +4856,6 @@ Action *Driver::ConstructPhaseAction(
types::TY_RewrittenLegacyObjC);
if (Args.hasArg(options::OPT__analyze))
return C.MakeAction<AnalyzeJobAction>(Input, types::TY_Plist);
- if (Args.hasArg(options::OPT__migrate))
- return C.MakeAction<MigrateJobAction>(Input, types::TY_Remap);
if (Args.hasArg(options::OPT_emit_ast))
return C.MakeAction<CompileJobAction>(Input, types::TY_AST);
if (Args.hasArg(options::OPT_emit_cir))
diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp
index 0d426a467e9a3b..a56f145df4d128 100644
--- a/clang/lib/Driver/ToolChain.cpp
+++ b/clang/lib/Driver/ToolChain.cpp
@@ -634,7 +634,6 @@ Tool *ToolChain::getTool(Action::ActionClass AC) const {
case Action::PreprocessJobClass:
case Action::ExtractAPIJobClass:
case Action::AnalyzeJobClass:
- case Action::MigrateJobClass:
case Action::VerifyPCHJobClass:
case Action::BackendJobClass:
return getClang();
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index 7ef55a33547c50..0be6b23fe7ca54 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -3938,78 +3938,6 @@ static void RenderOpenACCOptions(const Driver &D, const ArgList &Args,
}
}
-static void RenderARCMigrateToolOptions(const Driver &D, const ArgList &Args,
- ArgStringList &CmdArgs) {
- bool ARCMTEnabled = false;
- if (!Args.hasArg(options::OPT_fno_objc_arc, options::OPT_fobjc_arc)) {
- if (const Arg *A = Args.getLastArg(options::OPT_ccc_arcmt_check,
- options::OPT_ccc_arcmt_modify,
- options::OPT_ccc_arcmt_migrate)) {
- ARCMTEnabled = true;
- switch (A->getOption().getID()) {
- default: llvm_unreachable("missed a case");
- case options::OPT_ccc_arcmt_check:
- CmdArgs.push_back("-arcmt-action=check");
- break;
- case options::OPT_ccc_arcmt_modify:
- CmdArgs.push_back("-arcmt-action=modify");
- break;
- case options::OPT_ccc_arcmt_migrate:
- CmdArgs.push_back("-arcmt-action=migrate");
- CmdArgs.push_back("-mt-migrate-directory");
- CmdArgs.push_back(A->getValue());
-
- Args.AddLastArg(CmdArgs, options::OPT_arcmt_migrate_report_output);
- Args.AddLastArg(CmdArgs, options::OPT_arcmt_migrate_emit_arc_errors);
- break;
- }
- }
- } else {
- Args.ClaimAllArgs(options::OPT_ccc_arcmt_check);
- Args.ClaimAllArgs(options::OPT_ccc_arcmt_modify);
- Args.ClaimAllArgs(options::OPT_ccc_arcmt_migrate);
- }
-
- if (const Arg *A = Args.getLastArg(options::OPT_ccc_objcmt_migrate)) {
- if (ARCMTEnabled)
- D.Diag(diag::err_drv_argument_not_allowed_with)
- << A->getAsString(Args) << "-ccc-arcmt-migrate";
-
- CmdArgs.push_back("-mt-migrate-directory");
- CmdArgs.push_back(A->getValue());
-
- if (!Args.hasArg(options::OPT_objcmt_migrate_literals,
- options::OPT_objcmt_migrate_subscripting,
- options::OPT_objcmt_migrate_property)) {
- // None specified, means enable them all.
- CmdArgs.push_back("-objcmt-migrate-literals");
- CmdArgs.push_back("-objcmt-migrate-subscripting");
- CmdArgs.push_back("-objcmt-migrate-property");
- } else {
- Args.AddLastArg(CmdArgs, options::OPT_objcmt_migrate_literals);
- Args.AddLastArg(CmdArgs, options::OPT_objcmt_migrate_subscripting);
- Args.AddLastArg(CmdArgs, options::OPT_objcmt_migrate_property);
- }
- } else {
- Args.AddLastArg(CmdArgs, options::OPT_objcmt_migrate_literals);
- Args.AddLastArg(CmdArgs, options::OPT_objcmt_migrate_subscripting);
- Args.AddLastArg(CmdArgs, options::OPT_objcmt_migrate_property);
- Args.AddLastArg(CmdArgs, options::OPT_objcmt_migrate_all);
- Args.AddLastArg(CmdArgs, options::OPT_objcmt_migrate_readonly_property);
- Args.AddLastArg(CmdArgs, options::OPT_objcmt_migrate_readwrite_property);
- Args.AddLastArg(CmdArgs, options::OPT_objcmt_migrate_property_dot_syntax);
- Args.AddLastArg(CmdArgs, options::OPT_objcmt_migrate_annotation);
- Args.AddLastArg(CmdArgs, options::OPT_objcmt_migrate_instancetype);
- Args.AddLastArg(CmdArgs, options::OPT_objcmt_migrate_nsmacros);
- Args.AddLastArg(CmdArgs, options::OPT_objcmt_migrate_protocol_conformance);
- Args.AddLastArg(CmdArgs, options::OPT_objcmt_atomic_property);
- Args.AddLastArg(CmdArgs, options::OPT_objcmt_returns_innerpointer_property);
- Args.AddLastArg(CmdArgs, options::OPT_objcmt_ns_nonatomic_iosonly);
- Args.AddLastArg(CmdArgs, options::OPT_objcmt_migrate_designated_init);
- Args.AddLastArg(CmdArgs, options::OPT_objcmt_allowlist_dir_path);
- }
-}
-
static void RenderBuiltinOptions(const ToolChain &TC, const llvm::Triple &T,
const ArgList &Args, ArgStringList &CmdArgs) {
// -fbuiltin is default unless -mkernel is used.
@@ -5271,8 +5199,6 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
if (isa<AnalyzeJobAction>(JA)) {
assert(JA.getType() == types::TY_Plist && "Invalid output type.");
CmdArgs.push_back("-analyze");
- } else if (isa<MigrateJobAction>(JA)) {
- CmdArgs.push_back("-migrate");
} else if (isa<PreprocessJobAction>(JA)) {
if (Output.getType() == types::TY_Dependencies)
CmdArgs.push_back("-Eonly");
@@ -6397,8 +6323,6 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
Args.AddLastArg(CmdArgs, options::OPT_working_directory);
- RenderARCMigrateToolOptions(D, Args, CmdArgs);
-
// Add preprocessing options like -I, -D, etc. if we are using the
// preprocessor.
//
diff --git a/clang/lib/Driver/ToolChains/Darwin.cpp b/clang/lib/Driver/ToolChains/Darwin.cpp
index 87380869f6fdab..4b3cacaa513c5c 100644
--- a/clang/lib/Driver/ToolChains/Darwin.cpp
+++ b/clang/lib/Driver/ToolChains/Darwin.cpp
@@ -584,20 +584,6 @@ void darwin::Linker::ConstructJob(Compilation &C, const JobAction &JA,
// more information.
ArgStringList CmdArgs;
- /// Hack(tm) to ignore linking errors when we are doing ARC migration.
- if (Args.hasArg(options::OPT_ccc_arcmt_check,
- options::OPT_ccc_arcmt_migrate)) {
- for (const auto &Arg : Args)
- Arg->claim();
- const char *Exec =
- Args.MakeArgString(getToolChain().GetProgramPath("touch"));
- CmdArgs.push_back(Output.getFilename());
- C.addCommand(std::make_unique<Command>(JA, *this,
- ResponseFileSupport::None(), Exec,
- CmdArgs, std::nullopt, Output));
- return;
- }
-
VersionTuple Version = getMachOToolChain().getLinkerVersion(Args);
bool LinkerIsLLD;
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index 98136b7a455d9c..9db0a2c1f5eaee 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -2688,7 +2688,6 @@ static const auto &getFrontendActionTable() {
{frontend::RewriteObjC, OPT_rewrite_objc},
{frontend::RewriteTest, OPT_rewrite_test},
{frontend::RunAnalysis, OPT_analyze},
- {frontend::MigrateSource, OPT_migrate},
{frontend::RunPreprocessorOnly, OPT_Eonly},
{frontend::PrintDependencyDirectivesSourceMinimizerOutput,
OPT_print_dependency_directives_minimized_source},
@@ -3031,11 +3030,9 @@ static bool ParseFrontendArgs(FrontendOptions &Opts, ArgList &Args,
if (Args.hasArg(OPT_aux_target_feature))
Opts.AuxTargetFeatures = Args.getAllArgValues(OPT_aux_target_feature);
- if (Opts.ARCMTAction != FrontendOptions::ARCMT_None &&
- Opts.ObjCMTAction != FrontendOptions::ObjCMT_None) {
+ if (Opts.ObjCMTAction != FrontendOptions::ObjCMT_None)
Diags.Report(diag::err_drv_argument_not_allowed_with)
- << "ARC migration" << "ObjC migration";
- }
+ << "ARC migration";
InputKind DashX(Language::Unknown);
if (const Arg *A = Args.getLastArg(OPT_x)) {
@@ -4565,7 +4562,6 @@ static bool isStrictlyPreprocessorAction(frontend::ActionKind Action) {
case frontend::RewriteTest:
case frontend::RunAnalysis:
case frontend::TemplightDump:
- case frontend::MigrateSource:
return false;
case frontend::DumpCompilerOptions:
diff --git a/clang/lib/FrontendTool/CMakeLists.txt b/clang/lib/FrontendTool/CMakeLists.txt
index bfc7652b4c118f..d7a3699361f0aa 100644
--- a/clang/lib/FrontendTool/CMakeLists.txt
+++ b/clang/lib/FrontendTool/CMakeLists.txt
@@ -21,12 +21,6 @@ if(CLANG_ENABLE_CIR)
)
endif()
-if(CLANG_ENABLE_ARCMT)
- list(APPEND link_libs
- clangARCMigrate
- )
-endif()
-
if(CLANG_ENABLE_STATIC_ANALYZER)
list(APPEND link_libs
clangStaticAnalyzerFrontend
diff --git a/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp b/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
index 3f95a1efb2eed7..ed8ccdec0f75c7 100644
--- a/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
+++ b/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
@@ -11,7 +11,6 @@
//
//===----------------------------------------------------------------------===//
-#include "clang/ARCMigrate/ARCMTActions.h"
#include "clang/CodeGen/CodeGenAction.h"
#include "clang/Config/config.h"
#include "clang/Driver/Options.h"
@@ -169,35 +168,6 @@ CreateFrontendAction(CompilerInstance &CI) {
Act = std::make_unique<FixItRecompile>(std::move(Act));
}
-#if CLANG_ENABLE_ARCMT
- if (CI.getFrontendOpts().ProgramAction != frontend::MigrateSource &&
- CI.getFrontendOpts().ProgramAction != frontend::GeneratePCH) {
- // Potentially wrap the base FE action in an ARC Migrate Tool action.
- switch (FEOpts.ARCMTAction) {
- case FrontendOptions::ARCMT_None:
- break;
- case FrontendOptions::ARCMT_Check:
- Act = std::make_unique<arcmt::CheckAction>(std::move(Act));
- break;
- case FrontendOptions::ARCMT_Modify:
- Act = std::make_unique<arcmt::ModifyAction>(std::move(Act));
- break;
- case FrontendOptions::ARCMT_Migrate:
- Act = std::make_unique<arcmt::MigrateAction>(std::move(Act),
- FEOpts.MTMigrateDir,
- FEOpts.ARCMTMigrateReportOut,
- FEOpts.ARCMTMigrateEmitARCErrors);
- break;
- }
-
- if (FEOpts.ObjCMTAction != FrontendOptions::ObjCMT_None) {
- Act = std::make_unique<arcmt::ObjCMigrateAction>(std::move(Act),
- FEOpts.MTMigrateDir,
- FEOpts.ObjCMTAction);
- }
- }
-#endif
-
// Wrap the base FE action in an extract api action to generate
// symbol graph as a biproduct of compilation (enabled with
// --emit-symbol-graph option)
diff --git a/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp b/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
index 2e97cac0796cee..732de7b82475df 100644
--- a/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
+++ b/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
@@ -214,9 +214,6 @@ makeCommonInvocationForModuleBuild(CompilerInvocation CI) {
CI.getDependencyOutputOpts().Targets.clear();
CI.getFrontendOpts().ProgramAction = frontend::GenerateModule;
- CI.getFrontendOpts().ARCMTAction = FrontendOptions::ARCMT_None;
- CI.getFrontendOpts().ObjCMTAction = FrontendOptions::ObjCMT_None;
- CI.getFrontendOpts().MTMigrateDir.clear();
CI.getLangOpts().ModuleName.clear();
// Remove any macro definitions that are explicitly ignored.
diff --git a/clang/test/CMakeLists.txt b/clang/test/CMakeLists.txt
index 5369dc92f69e8a..9ce8365910d559 100644
--- a/clang/test/CMakeLists.txt
+++ b/clang/test/CMakeLists.txt
@@ -5,7 +5,6 @@ llvm_canonicalize_cmake_booleans(
CLANG_BUILD_EXAMPLES
CLANG_BUILT_STANDALONE
CLANG_DEFAULT_PIE_ON_LINUX
- CLANG_ENABLE_ARCMT
CLANG_ENABLE_STATIC_ANALYZER
CLANG_PLUGIN_SUPPORT
CLANG_SPAWN_CC1
@@ -92,13 +91,6 @@ if(CLANG_ENABLE_STATIC_ANALYZER)
)
endif()
-if (CLANG_ENABLE_ARCMT)
- list(APPEND CLANG_TEST_DEPS
- arcmt-test
- c-arcmt-test
- )
-endif ()
-
if(CLANG_BUILD_EXAMPLES AND CLANG_PLUGIN_SUPPORT)
list(APPEND CLANG_TEST_DEPS
Attribute
diff --git a/clang/test/ClangScanDeps/strip-input-args.m b/clang/test/ClangScanDeps/strip-input-args.m
index e1954ecc289144..31f634dd80131b 100644
--- a/clang/test/ClangScanDeps/strip-input-args.m
+++ b/clang/test/ClangScanDeps/strip-input-args.m
@@ -11,11 +11,6 @@
// CHECK: "modules": [
// CHECK-NEXT: {
-// CHECK: "command-line": [
-// CHECK-NOT: "-arcmt-action=check"
-// CHECK-NOT: "-objcmt-migrate-literals"
-// CHECK-NOT: "-mt-migrate-directory"
-// CHECK: ]
// CHECK: "name": "A"
// CHECK: }
// CHECK-NOT: "name": "A"
@@ -25,12 +20,12 @@
[
{
"directory": "DIR",
- "command": "clang -Imodules/A -fmodules -fmodules-cache-path=DIR/module-cache -fimplicit-modules -fimplicit-module-maps -ccc-arcmt-check -fsyntax-only DIR/t1.m",
+ "command": "clang -Imodules/A -fmodules -fmodules-cache-path=DIR/module-cache -fimplicit-modules -fimplicit-module-maps -fsyntax-only DIR/t1.m",
"file": "DIR/t1.m"
},
{
"directory": "DIR",
- "command": "clang -Imodules/A -fmodules -fmodules-cache-path=DIR/module-cache -fimplicit-modules -fimplicit-module-maps -ccc-objcmt-migrate bob -fsyntax-only DIR/t2.m",
+ "command": "clang -Imodules/A -fmodules -fmodules-cache-path=DIR/module-cache -fimplicit-modules -fimplicit-module-maps -fsyntax-only DIR/t2.m",
"file": "DIR/t2.m"
}
]
diff --git a/clang/test/Driver/objc-sdk-migration-options.m b/clang/test/Driver/objc-sdk-migration-options.m
deleted file mode 100644
index 8f7e5c72a3cffe..00000000000000
--- a/clang/test/Driver/objc-sdk-migration-options.m
+++ /dev/null
@@ -1,8 +0,0 @@
-// Check miscellaneous Objective-C sdk migration options.
-
-// RUN: %clang -objcmt-migrate-property-dot-syntax -target x86_64-apple-darwin10 -S -### %s \
-// RUN: -arch x86_64 2> %t
-// RUN: FileCheck < %t %s
-
-// CHECK: "-cc1"
-// CHECK: -objcmt-migrate-property-dot-syntax
diff --git a/clang/test/Misc/warning-flags.c b/clang/test/Misc/warning-flags.c
index 1fd02440833359..46b4e5a064c36f 100644
--- a/clang/test/Misc/warning-flags.c
+++ b/clang/test/Misc/warning-flags.c
@@ -18,7 +18,7 @@ This test serves two purposes:
The list of warnings below should NEVER grow. It should gradually shrink to 0.
-CHECK: Warnings without flags (61):
+CHECK: Warnings without flags (59):
CHECK-NEXT: ext_expected_semi_decl_list
CHECK-NEXT: ext_missing_whitespace_after_macro_name
@@ -32,7 +32,6 @@ CHECK-NEXT: pp_invalid_string_literal
CHECK-NEXT: pp_out_of_date_dependency
CHECK-NEXT: pp_poisoning_existing_macro
CHECK-NEXT: warn_accessor_property_type_mismatch
-CHECK-NEXT: warn_arcmt_nsalloc_realloc
CHECK-NEXT: warn_asm_label_on_auto_decl
CHECK-NEXT: warn_c_kext
CHECK-NEXT: warn_call_wrong_number_of_arguments
@@ -60,7 +59,6 @@ CHECK-NEXT: warn_method_param_redefinition
CHECK-NEXT: warn_missing_case_for_condition
CHECK-NEXT: warn_missing_dependent_template_keyword
CHECK-NEXT: warn_missing_whitespace_after_macro_name
-CHECK-NEXT: warn_mt_message
CHECK-NEXT: warn_no_constructor_for_refconst
CHECK-NEXT: warn_not_compound_assign
CHECK-NEXT: warn_objc_property_copy_missing_on_block
diff --git a/clang/test/lit.site.cfg.py.in b/clang/test/lit.site.cfg.py.in
index 1cbd876ac5bb93..0e27f5e0bfc957 100644
--- a/clang/test/lit.site.cfg.py.in
+++ b/clang/test/lit.site.cfg.py.in
@@ -22,7 +22,6 @@ config.host_cxx = "@CMAKE_CXX_COMPILER@"
config.llvm_use_sanitizer = "@LLVM_USE_SANITIZER@"
config.have_zlib = @LLVM_ENABLE_ZLIB@
config.have_zstd = @LLVM_ENABLE_ZSTD@
-config.clang_arcmt = @CLANG_ENABLE_ARCMT@
config.clang_default_pie_on_linux = @CLANG_DEFAULT_PIE_ON_LINUX@
config.clang_default_cxx_stdlib = "@CLANG_DEFAULT_CXX_STDLIB@"
config.clang_staticanalyzer = @CLANG_ENABLE_STATIC_ANALYZER@
diff --git a/clang/tools/CMakeLists.txt b/clang/tools/CMakeLists.txt
index 98c018e96848df..de0b47f3751f1a 100644
--- a/clang/tools/CMakeLists.txt
+++ b/clang/tools/CMakeLists.txt
@@ -27,11 +27,6 @@ if(UNIX OR (MSVC AND LLVM_BUILD_LLVM_DYLIB_VIS) OR (MINGW AND LLVM_LINK_LLVM_DYL
add_clang_subdirectory(clang-shlib)
endif()
-if(CLANG_ENABLE_ARCMT)
- add_clang_subdirectory(arcmt-test)
- add_clang_subdirectory(c-arcmt-test)
-endif()
-
if(CLANG_ENABLE_STATIC_ANALYZER)
add_clang_subdirectory(clang-check)
add_clang_subdirectory(clang-extdef-mapping)
diff --git a/clang/tools/arcmt-test/CMakeLists.txt b/clang/tools/arcmt-test/CMakeLists.txt
deleted file mode 100644
index d3e6580e16efaf..00000000000000
--- a/clang/tools/arcmt-test/CMakeLists.txt
+++ /dev/null
@@ -1,16 +0,0 @@
-set(LLVM_LINK_COMPONENTS
- support
- )
-
-add_clang_executable(arcmt-test
- arcmt-test.cpp
- )
-
-clang_target_link_libraries(arcmt-test
- PRIVATE
- clangARCMigrate
- clangBasic
- clangFrontend
- clangLex
- clangSerialization
- )
diff --git a/clang/tools/arcmt-test/arcmt-test.cpp b/clang/tools/arcmt-test/arcmt-test.cpp
deleted file mode 100644
index b61f38e9905dba..00000000000000
--- a/clang/tools/arcmt-test/arcmt-test.cpp
+++ /dev/null
@@ -1,376 +0,0 @@
-//===-- arcmt-test.cpp - ARC Migration Tool testbed -----------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#include "clang/ARCMigrate/ARCMT.h"
-#include "clang/AST/ASTContext.h"
-#include "clang/Frontend/PCHContainerOperations.h"
-#include "clang/Frontend/TextDiagnosticPrinter.h"
-#include "clang/Frontend/Utils.h"
-#include "clang/Frontend/VerifyDiagnosticConsumer.h"
-#include "clang/Lex/Preprocessor.h"
-#include "clang/Lex/PreprocessorOptions.h"
-#include "llvm/Support/FileSystem.h"
-#include "llvm/Support/MemoryBuffer.h"
-#include "llvm/Support/Path.h"
-#include "llvm/Support/Signals.h"
-#include <system_error>
-
-using namespace clang;
-using namespace arcmt;
-
-static llvm::cl::opt<bool>
-CheckOnly("check-only",
- llvm::cl::desc("Just check for issues that need to be handled manually"));
-
-//static llvm::cl::opt<bool>
-//TestResultForARC("test-result",
-//llvm::cl::desc("Test the result of transformations by parsing it in ARC mode"));
-
-static llvm::cl::opt<bool>
-OutputTransformations("output-transformations",
- llvm::cl::desc("Print the source transformations"));
-
-static llvm::cl::opt<bool>
-VerifyDiags("verify",llvm::cl::desc("Verify emitted diagnostics and warnings"));
-
-static llvm::cl::opt<bool>
-VerboseOpt("v", llvm::cl::desc("Enable verbose output"));
-
-static llvm::cl::opt<bool>
-VerifyTransformedFiles("verify-transformed-files",
-llvm::cl::desc("Read pairs of file mappings (typically the output of "
- "c-arcmt-test) and compare their contents with the filenames "
- "provided in command-line"));
-
-static llvm::cl::opt<std::string>
-RemappingsFile("remappings-file",
- llvm::cl::desc("Pairs of file mappings (typically the output of "
- "c-arcmt-test)"));
-
-static llvm::cl::list<std::string>
-ResultFiles(llvm::cl::Positional, llvm::cl::desc("<filename>..."));
-
-static llvm::cl::extrahelp extraHelp(
- "\nusage with compiler args: arcmt-test [options] --args [compiler flags]\n");
-
-// This function isn't referenced outside its translation unit, but it
-// can't use the "static" keyword because its address is used for
-// GetMainExecutable (since some platforms don't support taking the
-// address of main, and some platforms can't implement GetMainExecutable
-// without being given the address of a function in the main executable).
-std::string GetExecutablePath(const char *Argv0) {
- // This just needs to be some symbol in the binary; C++ doesn't
- // allow taking the address of ::main however.
- void *MainAddr = (void*) (intptr_t) GetExecutablePath;
- return llvm::sys::fs::getMainExecutable(Argv0, MainAddr);
-}
-
-static void printSourceLocation(SourceLocation loc, ASTContext &Ctx,
- raw_ostream &OS);
-static void printSourceRange(CharSourceRange range, ASTContext &Ctx,
- raw_ostream &OS);
-
-namespace {
-
-class PrintTransforms : public MigrationProcess::RewriteListener {
- ASTContext *Ctx;
- raw_ostream &OS;
-
-public:
- PrintTransforms(raw_ostream &OS)
- : Ctx(nullptr), OS(OS) {}
-
- void start(ASTContext &ctx) override { Ctx = &ctx; }
- void finish() override { Ctx = nullptr; }
-
- void insert(SourceLocation loc, StringRef text) override {
- assert(Ctx);
- OS << "Insert: ";
- printSourceLocation(loc, *Ctx, OS);
- OS << " \"" << text << "\"\n";
- }
-
- void remove(CharSourceRange range) override {
- assert(Ctx);
- OS << "Remove: ";
- printSourceRange(range, *Ctx, OS);
- OS << '\n';
- }
-};
-
-} // anonymous namespace
-
-static bool checkForMigration(StringRef resourcesPath,
- ArrayRef<const char *> Args) {
- IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts = new DiagnosticOptions();
- DiagnosticConsumer *DiagClient =
- new TextDiagnosticPrinter(llvm::errs(), &*DiagOpts);
- IntrusiveRefCntPtr<DiagnosticIDs> DiagID(new DiagnosticIDs());
- IntrusiveRefCntPtr<DiagnosticsEngine> Diags(
- new DiagnosticsEngine(DiagID, &*DiagOpts, DiagClient));
- // Chain in -verify checker, if requested.
- VerifyDiagnosticConsumer *verifyDiag = nullptr;
- if (VerifyDiags) {
- verifyDiag = new VerifyDiagnosticConsumer(*Diags);
- Diags->setClient(verifyDiag);
- }
-
- CompilerInvocation CI;
- if (!CompilerInvocation::CreateFromArgs(CI, Args, *Diags))
- return true;
-
- if (CI.getFrontendOpts().Inputs.empty()) {
- llvm::errs() << "error: no input files\n";
- return true;
- }
-
- if (!CI.getLangOpts().ObjC)
- return false;
-
- arcmt::checkForManualIssues(CI, CI.getFrontendOpts().Inputs[0],
- std::make_shared<PCHContainerOperations>(),
- Diags->getClient());
- return Diags->getClient()->getNumErrors() > 0;
-}
-
-static void printResult(FileRemapper &remapper, raw_ostream &OS) {
- remapper.forEachMapping([](StringRef, StringRef) {},
- [&](StringRef, const llvm::MemoryBufferRef &Buffer) {
- OS << Buffer.getBuffer();
- });
-}
-
-static bool performTransformations(StringRef resourcesPath,
- ArrayRef<const char *> Args) {
- // Check first.
- if (checkForMigration(resourcesPath, Args))
- return true;
-
- IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts = new DiagnosticOptions();
- DiagnosticConsumer *DiagClient =
- new TextDiagnosticPrinter(llvm::errs(), &*DiagOpts);
- IntrusiveRefCntPtr<DiagnosticIDs> DiagID(new DiagnosticIDs());
- IntrusiveRefCntPtr<DiagnosticsEngine> TopDiags(
- new DiagnosticsEngine(DiagID, &*DiagOpts, &*DiagClient));
-
- CompilerInvocation origCI;
- if (!CompilerInvocation::CreateFromArgs(origCI, Args, *TopDiags))
- return true;
-
- if (origCI.getFrontendOpts().Inputs.empty()) {
- llvm::errs() << "error: no input files\n";
- return true;
- }
-
- if (!origCI.getLangOpts().ObjC)
- return false;
-
- MigrationProcess migration(origCI, std::make_shared<PCHContainerOperations>(),
- DiagClient);
-
- std::vector<TransformFn>
- transforms = arcmt::getAllTransformations(origCI.getLangOpts().getGC(),
- origCI.getMigratorOpts().NoFinalizeRemoval);
- assert(!transforms.empty());
-
- std::unique_ptr<PrintTransforms> transformPrinter;
- if (OutputTransformations)
- transformPrinter.reset(new PrintTransforms(llvm::outs()));
-
- for (unsigned i=0, e = transforms.size(); i != e; ++i) {
- bool err = migration.applyTransform(transforms[i], transformPrinter.get());
- if (err) return true;
-
- if (VerboseOpt) {
- if (i == e-1)
- llvm::errs() << "\n##### FINAL RESULT #####\n";
- else
- llvm::errs() << "\n##### OUTPUT AFTER "<< i+1 <<". TRANSFORMATION #####\n";
- printResult(migration.getRemapper(), llvm::errs());
- llvm::errs() << "\n##########################\n\n";
- }
- }
-
- if (!OutputTransformations)
- printResult(migration.getRemapper(), llvm::outs());
-
- // FIXME: TestResultForARC
-
- return false;
-}
-
-static bool filesCompareEqual(StringRef fname1, StringRef fname2) {
- using namespace llvm;
-
- ErrorOr<std::unique_ptr<MemoryBuffer>> file1 =
- MemoryBuffer::getFile(fname1, /*IsText=*/true);
- if (!file1)
- return false;
-
- ErrorOr<std::unique_ptr<MemoryBuffer>> file2 =
- MemoryBuffer::getFile(fname2, /*IsText=*/true);
- if (!file2)
- return false;
-
- return file1.get()->getBuffer() == file2.get()->getBuffer();
-}
-
-static bool verifyTransformedFiles(ArrayRef<std::string> resultFiles) {
- using namespace llvm;
-
- assert(!resultFiles.empty());
-
- std::map<StringRef, StringRef> resultMap;
-
- for (ArrayRef<std::string>::iterator
- I = resultFiles.begin(), E = resultFiles.end(); I != E; ++I) {
- StringRef fname(*I);
- if (!fname.ends_with(".result")) {
- errs() << "error: filename '" << fname
- << "' does not have '.result' extension\n";
- return true;
- }
- resultMap[sys::path::stem(fname)] = fname;
- }
-
- ErrorOr<std::unique_ptr<MemoryBuffer>> inputBuf = std::error_code();
- if (RemappingsFile.empty())
- inputBuf = MemoryBuffer::getSTDIN();
- else
- inputBuf = MemoryBuffer::getFile(RemappingsFile, /*IsText=*/true);
- if (!inputBuf) {
- errs() << "error: could not read remappings input\n";
- return true;
- }
-
- SmallVector<StringRef, 8> strs;
- inputBuf.get()->getBuffer().split(strs, "\n", /*MaxSplit=*/-1,
- /*KeepEmpty=*/false);
-
- if (strs.empty()) {
- errs() << "error: no files to verify from stdin\n";
- return true;
- }
- if (strs.size() % 2 != 0) {
- errs() << "error: files to verify are not original/result pairs\n";
- return true;
- }
-
- for (unsigned i = 0, e = strs.size(); i != e; i += 2) {
- StringRef inputOrigFname = strs[i];
- StringRef inputResultFname = strs[i+1];
-
- std::map<StringRef, StringRef>::iterator It;
- It = resultMap.find(sys::path::filename(inputOrigFname));
- if (It == resultMap.end()) {
- errs() << "error: '" << inputOrigFname << "' is not in the list of "
- << "transformed files to verify\n";
- return true;
- }
-
- if (!sys::fs::exists(It->second)) {
- errs() << "error: '" << It->second << "' does not exist\n";
- return true;
- }
- if (!sys::fs::exists(inputResultFname)) {
- errs() << "error: '" << inputResultFname << "' does not exist\n";
- return true;
- }
-
- if (!filesCompareEqual(It->second, inputResultFname)) {
- errs() << "error: '" << It->second << "' is different than "
- << "'" << inputResultFname << "'\n";
- return true;
- }
-
- resultMap.erase(It);
- }
-
- if (!resultMap.empty()) {
- for (std::map<StringRef, StringRef>::iterator
- I = resultMap.begin(), E = resultMap.end(); I != E; ++I)
- errs() << "error: '" << I->second << "' was not verified!\n";
- return true;
- }
-
- return false;
-}
-
-//===----------------------------------------------------------------------===//
-// Misc. functions.
-//===----------------------------------------------------------------------===//
-
-static void printSourceLocation(SourceLocation loc, ASTContext &Ctx,
- raw_ostream &OS) {
- SourceManager &SM = Ctx.getSourceManager();
- PresumedLoc PL = SM.getPresumedLoc(loc);
-
- OS << llvm::sys::path::filename(PL.getFilename());
- OS << ":" << PL.getLine() << ":"
- << PL.getColumn();
-}
-
-static void printSourceRange(CharSourceRange range, ASTContext &Ctx,
- raw_ostream &OS) {
- SourceManager &SM = Ctx.getSourceManager();
- const LangOptions &langOpts = Ctx.getLangOpts();
-
- PresumedLoc PL = SM.getPresumedLoc(range.getBegin());
-
- OS << llvm::sys::path::filename(PL.getFilename());
- OS << " [" << PL.getLine() << ":"
- << PL.getColumn();
- OS << " - ";
-
- SourceLocation end = range.getEnd();
- PL = SM.getPresumedLoc(end);
-
- unsigned endCol = PL.getColumn() - 1;
- if (!range.isTokenRange())
- endCol += Lexer::MeasureTokenLength(end, SM, langOpts);
- OS << PL.getLine() << ":" << endCol << "]";
-}
-
-//===----------------------------------------------------------------------===//
-// Command line processing.
-//===----------------------------------------------------------------------===//
-
-int main(int argc, const char **argv) {
- void *MainAddr = (void*) (intptr_t) GetExecutablePath;
- llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
-
- std::string
- resourcesPath = CompilerInvocation::GetResourcesPath(argv[0], MainAddr);
-
- int optargc = 0;
- for (; optargc != argc; ++optargc) {
- if (StringRef(argv[optargc]) == "--args")
- break;
- }
- llvm::cl::ParseCommandLineOptions(optargc, argv, "arcmt-test");
-
- if (VerifyTransformedFiles) {
- if (ResultFiles.empty()) {
- llvm::cl::PrintHelpMessage();
- return 1;
- }
- return verifyTransformedFiles(ResultFiles);
- }
-
- if (optargc == argc) {
- llvm::cl::PrintHelpMessage();
- return 1;
- }
-
- ArrayRef<const char*> Args(argv+optargc+1, argc-optargc-1);
-
- if (CheckOnly)
- return checkForMigration(resourcesPath, Args);
-
- return performTransformations(resourcesPath, Args);
-}
diff --git a/clang/tools/c-arcmt-test/CMakeLists.txt b/clang/tools/c-arcmt-test/CMakeLists.txt
deleted file mode 100644
index 08ac93c176db12..00000000000000
--- a/clang/tools/c-arcmt-test/CMakeLists.txt
+++ /dev/null
@@ -1,19 +0,0 @@
-add_clang_executable(c-arcmt-test
- c-arcmt-test.c
- )
-
-if (LLVM_BUILD_STATIC)
- target_link_libraries(c-arcmt-test
- PRIVATE
- libclang_static
- )
-else()
- target_link_libraries(c-arcmt-test
- PRIVATE
- libclang
- )
-endif()
-
-set_target_properties(c-arcmt-test
- PROPERTIES
- LINKER_LANGUAGE CXX)
diff --git a/clang/tools/c-arcmt-test/c-arcmt-test.c b/clang/tools/c-arcmt-test/c-arcmt-test.c
deleted file mode 100644
index 4d0c418714b950..00000000000000
--- a/clang/tools/c-arcmt-test/c-arcmt-test.c
+++ /dev/null
@@ -1,138 +0,0 @@
-/* c-arcmt-test.c */
-
-#include "clang-c/Index.h"
-#include "llvm/Support/AutoConvert.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#if defined(_WIN32)
-#include <io.h>
-#include <fcntl.h>
-#endif
-
-static int print_remappings(const char *path) {
- CXRemapping remap;
- unsigned i, N;
- CXString origFname;
- CXString transFname;
-
- remap = clang_getRemappings(path);
- if (!remap)
- return 1;
-
- N = clang_remap_getNumFiles(remap);
- for (i = 0; i != N; ++i) {
- clang_remap_getFilenames(remap, i, &origFname, &transFname);
-
- fprintf(stdout, "%s\n", clang_getCString(origFname));
- fprintf(stdout, "%s\n", clang_getCString(transFname));
-
- clang_disposeString(origFname);
- clang_disposeString(transFname);
- }
-
- clang_remap_dispose(remap);
- return 0;
-}
-
-static int print_remappings_filelist(const char **files, unsigned numFiles) {
- CXRemapping remap;
- unsigned i, N;
- CXString origFname;
- CXString transFname;
-
- remap = clang_getRemappingsFromFileList(files, numFiles);
- if (!remap)
- return 1;
-
- N = clang_remap_getNumFiles(remap);
- for (i = 0; i != N; ++i) {
- clang_remap_getFilenames(remap, i, &origFname, &transFname);
-
- fprintf(stdout, "%s\n", clang_getCString(origFname));
- fprintf(stdout, "%s\n", clang_getCString(transFname));
-
- clang_disposeString(origFname);
- clang_disposeString(transFname);
- }
-
- clang_remap_dispose(remap);
- return 0;
-}
-
-/******************************************************************************/
-/* Command line processing. */
-/******************************************************************************/
-
-static void print_usage(void) {
- fprintf(stderr,
- "usage: c-arcmt-test -mt-migrate-directory <path>\n"
- " c-arcmt-test <remap-file-path1> <remap-file-path2> ...\n\n\n");
-}
-
-/***/
-
-int carcmttest_main(int argc, const char **argv) {
- clang_enableStackTraces();
- if (argc == 3 && strncmp(argv[1], "-mt-migrate-directory", 21) == 0)
- return print_remappings(argv[2]);
-
- if (argc > 1)
- return print_remappings_filelist(argv+1, argc-1);
-
- print_usage();
- return 1;
-}
-
-/***/
-
-/* We intentionally run in a separate thread to ensure we at least minimal
- * testing of a multithreaded environment (for example, having a reduced stack
- * size). */
-
-typedef struct thread_info {
- int argc;
- const char **argv;
- int result;
-} thread_info;
-void thread_runner(void *client_data_v) {
- thread_info *client_data = client_data_v;
- client_data->result = carcmttest_main(client_data->argc, client_data->argv);
-}
-
-static void flush_atexit(void) {
- /* stdout, and surprisingly even stderr, are not always flushed on process
- * and thread exit, particularly when the system is under heavy load. */
- fflush(stdout);
- fflush(stderr);
-}
-
-int main(int argc, const char **argv) {
-#ifdef __MVS__
- if (enablezOSAutoConversion(fileno(stdout)) == -1)
- fprintf(stderr, "Setting conversion on stdout failed\n");
-
- if (enablezOSAutoConversion(fileno(stderr)) == -1)
- fprintf(stderr, "Setting conversion on stderr failed\n");
-#endif
-
- thread_info client_data;
-
- atexit(flush_atexit);
-
-#if defined(_WIN32)
- if (getenv("LIBCLANG_LOGGING") == NULL)
- putenv("LIBCLANG_LOGGING=1");
- _setmode( _fileno(stdout), _O_BINARY );
-#else
- setenv("LIBCLANG_LOGGING", "1", /*overwrite=*/0);
-#endif
-
- if (getenv("CINDEXTEST_NOTHREADS"))
- return carcmttest_main(argc, argv);
-
- client_data.argc = argc;
- client_data.argv = argv;
- clang_executeOnThread(thread_runner, &client_data, 0);
- return client_data.result;
-}
diff --git a/clang/tools/libclang/ARCMigrate.cpp b/clang/tools/libclang/ARCMigrate.cpp
deleted file mode 100644
index da8a7e4b9130b9..00000000000000
--- a/clang/tools/libclang/ARCMigrate.cpp
+++ /dev/null
@@ -1,138 +0,0 @@
-//===- ARCMigrate.cpp - Clang-C ARC Migration Library ---------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-//
-// This file implements the main API hooks in the Clang-C ARC Migration library.
-//
-//===----------------------------------------------------------------------===//
-
-#include "clang-c/Index.h"
-#include "CXString.h"
-#include "clang/ARCMigrate/ARCMT.h"
-#include "clang/Config/config.h"
-#include "clang/Frontend/TextDiagnosticBuffer.h"
-#include "llvm/Support/FileSystem.h"
-
-using namespace clang;
-using namespace arcmt;
-
-namespace {
-
-struct Remap {
- std::vector<std::pair<std::string, std::string> > Vec;
-};
-
-} // anonymous namespace.
-
-//===----------------------------------------------------------------------===//
-// libClang public APIs.
-//===----------------------------------------------------------------------===//
-
-CXRemapping clang_getRemappings(const char *migrate_dir_path) {
-#if !CLANG_ENABLE_ARCMT
- llvm::errs() << "error: feature not enabled in this build\n";
- return nullptr;
-#else
- bool Logging = ::getenv("LIBCLANG_LOGGING");
-
- if (!migrate_dir_path) {
- if (Logging)
- llvm::errs() << "clang_getRemappings was called with NULL parameter\n";
- return nullptr;
- }
-
- if (!llvm::sys::fs::exists(migrate_dir_path)) {
- if (Logging) {
- llvm::errs() << "Error by clang_getRemappings(\"" << migrate_dir_path
- << "\")\n";
- llvm::errs() << "\"" << migrate_dir_path << "\" does not exist\n";
- }
- return nullptr;
- }
-
- TextDiagnosticBuffer diagBuffer;
- std::unique_ptr<Remap> remap(new Remap());
-
- bool err = arcmt::getFileRemappings(remap->Vec, migrate_dir_path,&diagBuffer);
-
- if (err) {
- if (Logging) {
- llvm::errs() << "Error by clang_getRemappings(\"" << migrate_dir_path
- << "\")\n";
- for (TextDiagnosticBuffer::const_iterator
- I = diagBuffer.err_begin(), E = diagBuffer.err_end(); I != E; ++I)
- llvm::errs() << I->second << '\n';
- }
- return nullptr;
- }
-
- return remap.release();
-#endif
-}
-
-CXRemapping clang_getRemappingsFromFileList(const char **filePaths,
- unsigned numFiles) {
-#if !CLANG_ENABLE_ARCMT
- llvm::errs() << "error: feature not enabled in this build\n";
- return nullptr;
-#else
- bool Logging = ::getenv("LIBCLANG_LOGGING");
-
- std::unique_ptr<Remap> remap(new Remap());
-
- if (numFiles == 0) {
- if (Logging)
- llvm::errs() << "clang_getRemappingsFromFileList was called with "
- "numFiles=0\n";
- return remap.release();
- }
-
- if (!filePaths) {
- if (Logging)
- llvm::errs() << "clang_getRemappingsFromFileList was called with "
- "NULL filePaths\n";
- return nullptr;
- }
-
- TextDiagnosticBuffer diagBuffer;
- SmallVector<StringRef, 32> Files(filePaths, filePaths + numFiles);
-
- bool err = arcmt::getFileRemappingsFromFileList(remap->Vec, Files,
- &diagBuffer);
-
- if (err) {
- if (Logging) {
- llvm::errs() << "Error by clang_getRemappingsFromFileList\n";
- for (TextDiagnosticBuffer::const_iterator
- I = diagBuffer.err_begin(), E = diagBuffer.err_end(); I != E; ++I)
- llvm::errs() << I->second << '\n';
- }
- return remap.release();
- }
-
- return remap.release();
-#endif
-}
-
-unsigned clang_remap_getNumFiles(CXRemapping map) {
- return static_cast<Remap *>(map)->Vec.size();
-
-}
-
-void clang_remap_getFilenames(CXRemapping map, unsigned index,
- CXString *original, CXString *transformed) {
- if (original)
- *original = cxstring::createDup(
- static_cast<Remap *>(map)->Vec[index].first);
- if (transformed)
- *transformed = cxstring::createDup(
- static_cast<Remap *>(map)->Vec[index].second);
-}
-
-void clang_remap_dispose(CXRemapping map) {
- delete static_cast<Remap *>(map);
-}
diff --git a/clang/tools/libclang/CMakeLists.txt b/clang/tools/libclang/CMakeLists.txt
index 00a1223c0831a7..299c14660f3d4c 100644
--- a/clang/tools/libclang/CMakeLists.txt
+++ b/clang/tools/libclang/CMakeLists.txt
@@ -20,7 +20,6 @@ endif()
# to clean up previous inconsistencies.
set(SOURCES
- ARCMigrate.cpp
BuildSystem.cpp
CIndex.cpp
CIndexCXX.cpp
@@ -71,10 +70,6 @@ set(LIBS
clangTooling
)
-if (CLANG_ENABLE_ARCMT)
- list(APPEND LIBS clangARCMigrate)
-endif ()
-
if (HAVE_LIBDL)
list(APPEND LIBS ${CMAKE_DL_LIBS})
elseif (CLANG_BUILT_STANDALONE)
@@ -208,9 +203,6 @@ if(ENABLE_SHARED)
target_link_options(libclang PRIVATE "-Wl,--version-script,${CMAKE_CURRENT_SOURCE_DIR}/libclang.map")
endif()
# Ensure that libclang.so gets rebuilt when the linker script changes.
- set_property(SOURCE ARCMigrate.cpp APPEND PROPERTY
- OBJECT_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/libclang.map)
-
set_target_properties(libclang PROPERTIES
VERSION ${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}${LLVM_VERSION_SUFFIX}
${LIBCLANG_SOVERSION_ARG})
diff --git a/clang/tools/libclang/libclang.map b/clang/tools/libclang/libclang.map
index 25d8ba57d32514..e274cfd010b3b9 100644
--- a/clang/tools/libclang/libclang.map
+++ b/clang/tools/libclang/libclang.map
@@ -327,8 +327,6 @@ LLVM_13 {
clang_getRange;
clang_getRangeEnd;
clang_getRangeStart;
- clang_getRemappings;
- clang_getRemappingsFromFileList;
clang_getResultType;
clang_getSkippedRanges;
clang_getSpecializedCursorTemplate;
@@ -389,9 +387,6 @@ LLVM_13 {
clang_parseTranslationUnit;
clang_parseTranslationUnit2;
clang_parseTranslationUnit2FullArgv;
- clang_remap_dispose;
- clang_remap_getFilenames;
- clang_remap_getNumFiles;
clang_reparseTranslationUnit;
clang_saveTranslationUnit;
clang_sortCodeCompletionResults;
diff --git a/clang/unittests/Basic/DiagnosticTest.cpp b/clang/unittests/Basic/DiagnosticTest.cpp
index 36a77c7247655f..419ca257308540 100644
--- a/clang/unittests/Basic/DiagnosticTest.cpp
+++ b/clang/unittests/Basic/DiagnosticTest.cpp
@@ -60,7 +60,7 @@ TEST(DiagnosticTest, suppressAndTrap) {
// Diag that would set FatalErrorOccurred
// (via non-note following a fatal error).
- Diags.Report(diag::warn_mt_message) << "warning";
+ Diags.Report(diag::warn_apinotes_message) << "warning";
EXPECT_TRUE(trap.hasErrorOccurred());
EXPECT_TRUE(trap.hasUnrecoverableErrorOccurred());
@@ -85,7 +85,7 @@ TEST(DiagnosticTest, fatalsAsError) {
// Diag that would set FatalErrorOccurred
// (via non-note following a fatal error).
- Diags.Report(diag::warn_mt_message) << "warning";
+ Diags.Report(diag::warn_apinotes_message) << "warning";
EXPECT_TRUE(Diags.hasErrorOccurred());
EXPECT_EQ(Diags.hasFatalErrorOccurred(), FatalsAsError ? 0u : 1u);
diff --git a/clang/utils/analyzer/entrypoint.py b/clang/utils/analyzer/entrypoint.py
index 4deb42db0a0b1f..c8dfc1a9f2ed84 100644
--- a/clang/utils/analyzer/entrypoint.py
+++ b/clang/utils/analyzer/entrypoint.py
@@ -54,7 +54,6 @@ def is_cmake_needed():
"cmake -G Ninja -DCMAKE_BUILD_TYPE=Release "
"-DCMAKE_INSTALL_PREFIX=/analyzer -DLLVM_TARGETS_TO_BUILD=X86 "
'-DLLVM_ENABLE_PROJECTS="clang;openmp" -DLLVM_BUILD_RUNTIME=OFF '
- "-DCLANG_ENABLE_ARCMT=OFF "
"-DCLANG_ENABLE_STATIC_ANALYZER=ON"
)
>From a30ac6d1aa76a876e36d6d9e01ff82f77880847f Mon Sep 17 00:00:00 2001
From: Sirraide <aeternalmail at gmail.com>
Date: Fri, 17 Jan 2025 03:51:16 +0100
Subject: [PATCH 3/7] And more references
---
clang/include/clang-c/Index.h | 60 -------------------
clang/lib/Frontend/CompilerInvocation.cpp | 4 --
.../ExecuteCompilerInvocation.cpp | 9 +--
3 files changed, 1 insertion(+), 72 deletions(-)
diff --git a/clang/include/clang-c/Index.h b/clang/include/clang-c/Index.h
index 8fc06328f0bcef..ee9e159b6dad76 100644
--- a/clang/include/clang-c/Index.h
+++ b/clang/include/clang-c/Index.h
@@ -5850,66 +5850,6 @@ CINDEX_LINKAGE const char *clang_EvalResult_getAsStr(CXEvalResult E);
* Disposes the created Eval memory.
*/
CINDEX_LINKAGE void clang_EvalResult_dispose(CXEvalResult E);
-/**
- * @}
- */
-
-/** \defgroup CINDEX_REMAPPING Remapping functions
- *
- * @{
- */
-
-/**
- * A remapping of original source files and their translated files.
- */
-typedef void *CXRemapping;
-
-/**
- * Retrieve a remapping.
- *
- * \param path the path that contains metadata about remappings.
- *
- * \returns the requested remapping. This remapping must be freed
- * via a call to \c clang_remap_dispose(). Can return NULL if an error occurred.
- */
-CINDEX_LINKAGE CXRemapping clang_getRemappings(const char *path);
-
-/**
- * Retrieve a remapping.
- *
- * \param filePaths pointer to an array of file paths containing remapping info.
- *
- * \param numFiles number of file paths.
- *
- * \returns the requested remapping. This remapping must be freed
- * via a call to \c clang_remap_dispose(). Can return NULL if an error occurred.
- */
-CINDEX_LINKAGE
-CXRemapping clang_getRemappingsFromFileList(const char **filePaths,
- unsigned numFiles);
-
-/**
- * Determine the number of remappings.
- */
-CINDEX_LINKAGE unsigned clang_remap_getNumFiles(CXRemapping);
-
-/**
- * Get the original and the associated filename from the remapping.
- *
- * \param original If non-NULL, will be set to the original filename.
- *
- * \param transformed If non-NULL, will be set to the filename that the original
- * is associated with.
- */
-CINDEX_LINKAGE void clang_remap_getFilenames(CXRemapping, unsigned index,
- CXString *original,
- CXString *transformed);
-
-/**
- * Dispose the remapping.
- */
-CINDEX_LINKAGE void clang_remap_dispose(CXRemapping);
-
/**
* @}
*/
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index 9db0a2c1f5eaee..387bbc5408a2d0 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -3030,10 +3030,6 @@ static bool ParseFrontendArgs(FrontendOptions &Opts, ArgList &Args,
if (Args.hasArg(OPT_aux_target_feature))
Opts.AuxTargetFeatures = Args.getAllArgValues(OPT_aux_target_feature);
- if (Opts.ObjCMTAction != FrontendOptions::ObjCMT_None)
- Diags.Report(diag::err_drv_argument_not_allowed_with)
- << "ARC migration";
-
InputKind DashX(Language::Unknown);
if (const Arg *A = Args.getLastArg(OPT_x)) {
StringRef XValue = A->getValue();
diff --git a/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp b/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
index ed8ccdec0f75c7..079bcd93d6162a 100644
--- a/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
+++ b/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
@@ -130,12 +130,6 @@ CreateFrontendBaseAction(CompilerInstance &CI) {
#else
case RewriteObjC: Action = "RewriteObjC"; break;
#endif
-#if CLANG_ENABLE_ARCMT
- case MigrateSource:
- return std::make_unique<arcmt::MigrateSourceAction>();
-#else
- case MigrateSource: Action = "MigrateSource"; break;
-#endif
#if CLANG_ENABLE_STATIC_ANALYZER
case RunAnalysis: return std::make_unique<ento::AnalysisAction>();
#else
@@ -146,8 +140,7 @@ CreateFrontendBaseAction(CompilerInstance &CI) {
return std::make_unique<PrintDependencyDirectivesSourceMinimizerAction>();
}
-#if !CLANG_ENABLE_ARCMT || !CLANG_ENABLE_STATIC_ANALYZER \
- || !CLANG_ENABLE_OBJC_REWRITER
+#if !CLANG_ENABLE_STATIC_ANALYZER || !CLANG_ENABLE_OBJC_REWRITER
CI.getDiagnostics().Report(diag::err_fe_action_not_available) << Action;
return 0;
#else
>From 5e5e6e9b32285ad0550abfd9dc74fa56081eb6b6 Mon Sep 17 00:00:00 2001
From: Sirraide <aeternalmail at gmail.com>
Date: Fri, 17 Jan 2025 03:53:08 +0100
Subject: [PATCH 4/7] Remove gn files for ARCMigrate
---
llvm/utils/gn/secondary/BUILD.gn | 1 -
.../clang/include/clang/Config/BUILD.gn | 7 ----
.../secondary/clang/lib/ARCMigrate/BUILD.gn | 39 -------------------
.../secondary/clang/lib/ARCMigrate/enable.gni | 4 --
.../secondary/clang/lib/FrontendTool/BUILD.gn | 7 ----
llvm/utils/gn/secondary/clang/test/BUILD.gn | 13 -------
.../secondary/clang/tools/arcmt-test/BUILD.gn | 11 ------
.../clang/tools/c-arcmt-test/BUILD.gn | 11 ------
.../secondary/clang/tools/libclang/BUILD.gn | 5 ---
9 files changed, 98 deletions(-)
delete mode 100644 llvm/utils/gn/secondary/clang/lib/ARCMigrate/BUILD.gn
delete mode 100644 llvm/utils/gn/secondary/clang/lib/ARCMigrate/enable.gni
delete mode 100644 llvm/utils/gn/secondary/clang/tools/arcmt-test/BUILD.gn
delete mode 100644 llvm/utils/gn/secondary/clang/tools/c-arcmt-test/BUILD.gn
diff --git a/llvm/utils/gn/secondary/BUILD.gn b/llvm/utils/gn/secondary/BUILD.gn
index 5590a5ba195e2b..72c4476a147892 100644
--- a/llvm/utils/gn/secondary/BUILD.gn
+++ b/llvm/utils/gn/secondary/BUILD.gn
@@ -1,4 +1,3 @@
-import("//clang/lib/ARCMigrate/enable.gni")
import("//clang/lib/StaticAnalyzer/Frontend/enable.gni")
import("//llvm/utils/gn/build/toolchain/compiler.gni")
diff --git a/llvm/utils/gn/secondary/clang/include/clang/Config/BUILD.gn b/llvm/utils/gn/secondary/clang/include/clang/Config/BUILD.gn
index bc0631dc269ac7..9678bce7c0459e 100644
--- a/llvm/utils/gn/secondary/clang/include/clang/Config/BUILD.gn
+++ b/llvm/utils/gn/secondary/clang/include/clang/Config/BUILD.gn
@@ -1,4 +1,3 @@
-import("//clang/lib/ARCMigrate/enable.gni")
import("//clang/lib/StaticAnalyzer/Frontend/enable.gni")
import("//llvm/utils/gn/build/libs/xml/enable.gni")
import("//llvm/utils/gn/build/write_cmake_config.gni")
@@ -32,12 +31,6 @@ write_cmake_config("Config") {
"PPC_LINUX_DEFAULT_IEEELONGDOUBLE=",
]
- if (clang_enable_arcmt) {
- values += [ "CLANG_ENABLE_ARCMT=1" ]
- } else {
- values += [ "CLANG_ENABLE_ARCMT=" ]
- }
-
if (clang_enable_static_analyzer) {
values += [ "CLANG_ENABLE_STATIC_ANALYZER=1" ]
} else {
diff --git a/llvm/utils/gn/secondary/clang/lib/ARCMigrate/BUILD.gn b/llvm/utils/gn/secondary/clang/lib/ARCMigrate/BUILD.gn
deleted file mode 100644
index 8a790c0875ac08..00000000000000
--- a/llvm/utils/gn/secondary/clang/lib/ARCMigrate/BUILD.gn
+++ /dev/null
@@ -1,39 +0,0 @@
-static_library("ARCMigrate") {
- output_name = "clangARCMigrate"
- configs += [ "//llvm/utils/gn/build:clang_code" ]
- deps = [
- "//clang/lib/AST",
- "//clang/lib/Analysis",
- "//clang/lib/Basic",
- "//clang/lib/Edit",
- "//clang/lib/Frontend",
- "//clang/lib/Lex",
- "//clang/lib/Rewrite",
- "//clang/lib/Sema",
- "//clang/lib/Serialization",
- "//llvm/lib/Support",
- "//llvm/lib/TargetParser",
- ]
- sources = [
- "ARCMT.cpp",
- "ARCMTActions.cpp",
- "FileRemapper.cpp",
- "ObjCMT.cpp",
- "PlistReporter.cpp",
- "TransAPIUses.cpp",
- "TransARCAssign.cpp",
- "TransAutoreleasePool.cpp",
- "TransBlockObjCVariable.cpp",
- "TransEmptyStatementsAndDealloc.cpp",
- "TransGCAttrs.cpp",
- "TransGCCalls.cpp",
- "TransProperties.cpp",
- "TransProtectedScope.cpp",
- "TransRetainReleaseDealloc.cpp",
- "TransUnbridgedCasts.cpp",
- "TransUnusedInitDelegate.cpp",
- "TransZeroOutPropsInDealloc.cpp",
- "TransformActions.cpp",
- "Transforms.cpp",
- ]
-}
diff --git a/llvm/utils/gn/secondary/clang/lib/ARCMigrate/enable.gni b/llvm/utils/gn/secondary/clang/lib/ARCMigrate/enable.gni
deleted file mode 100644
index 7a7a42edbfd42b..00000000000000
--- a/llvm/utils/gn/secondary/clang/lib/ARCMigrate/enable.gni
+++ /dev/null
@@ -1,4 +0,0 @@
-declare_args() {
- # Whether to include the arc migrate tool in the clang binary.
- clang_enable_arcmt = true
-}
diff --git a/llvm/utils/gn/secondary/clang/lib/FrontendTool/BUILD.gn b/llvm/utils/gn/secondary/clang/lib/FrontendTool/BUILD.gn
index 15d838a45aed39..9f7140ed391ddc 100644
--- a/llvm/utils/gn/secondary/clang/lib/FrontendTool/BUILD.gn
+++ b/llvm/utils/gn/secondary/clang/lib/FrontendTool/BUILD.gn
@@ -1,9 +1,5 @@
-import("//clang/lib/ARCMigrate/enable.gni")
import("//clang/lib/StaticAnalyzer/Frontend/enable.gni")
-assert(clang_enable_static_analyzer || !clang_enable_arcmt,
- "Cannot disable static analyzer while enabling ARCMT")
-
static_library("FrontendTool") {
output_name = "clangFrontendTool"
configs += [ "//llvm/utils/gn/build:clang_code" ]
@@ -18,9 +14,6 @@ static_library("FrontendTool") {
"//llvm/lib/Option",
"//llvm/lib/Support",
]
- if (clang_enable_arcmt) {
- deps += [ "//clang/lib/ARCMigrate" ]
- }
if (clang_enable_static_analyzer) {
deps += [ "//clang/lib/StaticAnalyzer/Frontend" ]
}
diff --git a/llvm/utils/gn/secondary/clang/test/BUILD.gn b/llvm/utils/gn/secondary/clang/test/BUILD.gn
index 41edc072a55e7d..e9b4c55edcf549 100644
--- a/llvm/utils/gn/secondary/clang/test/BUILD.gn
+++ b/llvm/utils/gn/secondary/clang/test/BUILD.gn
@@ -1,4 +1,3 @@
-import("//clang/lib/ARCMigrate/enable.gni")
import("//clang/lib/StaticAnalyzer/Frontend/enable.gni")
import("//llvm/include/llvm/Config/config.gni")
import("//llvm/lib/Target/targets.gni")
@@ -76,12 +75,6 @@ write_lit_config("lit_site_cfg") {
"PPC_LINUX_DEFAULT_IEEELONGDOUBLE=0",
]
- if (clang_enable_arcmt) {
- extra_values += [ "CLANG_ENABLE_ARCMT=1" ]
- } else {
- extra_values += [ "CLANG_ENABLE_ARCMT=0" ]
- }
-
if (clang_enable_static_analyzer) {
extra_values += [ "CLANG_ENABLE_STATIC_ANALYZER=1" ]
} else {
@@ -210,12 +203,6 @@ group("test") {
"//llvm/utils/not",
"//llvm/utils/split-file",
]
- if (clang_enable_arcmt) {
- deps += [
- "//clang/tools/arcmt-test",
- "//clang/tools/c-arcmt-test",
- ]
- }
if (clang_enable_static_analyzer) {
deps += [
"//clang/tools/clang-check",
diff --git a/llvm/utils/gn/secondary/clang/tools/arcmt-test/BUILD.gn b/llvm/utils/gn/secondary/clang/tools/arcmt-test/BUILD.gn
deleted file mode 100644
index 8d7fece1bc0244..00000000000000
--- a/llvm/utils/gn/secondary/clang/tools/arcmt-test/BUILD.gn
+++ /dev/null
@@ -1,11 +0,0 @@
-executable("arcmt-test") {
- configs += [ "//llvm/utils/gn/build:clang_code" ]
- deps = [
- "//clang/lib/ARCMigrate",
- "//clang/lib/Basic",
- "//clang/lib/Frontend",
- "//clang/lib/Lex",
- "//llvm/lib/Support",
- ]
- sources = [ "arcmt-test.cpp" ]
-}
diff --git a/llvm/utils/gn/secondary/clang/tools/c-arcmt-test/BUILD.gn b/llvm/utils/gn/secondary/clang/tools/c-arcmt-test/BUILD.gn
deleted file mode 100644
index a1c8fe10b59048..00000000000000
--- a/llvm/utils/gn/secondary/clang/tools/c-arcmt-test/BUILD.gn
+++ /dev/null
@@ -1,11 +0,0 @@
-executable("c-arcmt-test") {
- configs += [ "//llvm/utils/gn/build:clang_code" ]
- deps = [ "//clang/tools/libclang" ]
- sources = [ "c-arcmt-test.c" ]
-
- # See comment at top of clang/tools/libclang/BUILD.gn for why this isn't
- # needed on Linux.
- if (host_os == "mac") {
- ldflags = [ "-Wl,-rpath, at loader_path/../lib" ]
- }
-}
diff --git a/llvm/utils/gn/secondary/clang/tools/libclang/BUILD.gn b/llvm/utils/gn/secondary/clang/tools/libclang/BUILD.gn
index 9ec7dc975721a5..8f7beea152ab7b 100644
--- a/llvm/utils/gn/secondary/clang/tools/libclang/BUILD.gn
+++ b/llvm/utils/gn/secondary/clang/tools/libclang/BUILD.gn
@@ -1,4 +1,3 @@
-import("//clang/lib/ARCMigrate/enable.gni")
import("//llvm/utils/gn/build/symbol_exports.gni")
import("//llvm/version.gni")
@@ -48,9 +47,6 @@ shared_library("libclang") {
ldflags =
[ "-Wl,--version-script," + rebase_path(inputs[0], root_build_dir) ]
}
- if (clang_enable_arcmt) {
- deps += [ "//clang/lib/ARCMigrate" ]
- }
defines = []
@@ -60,7 +56,6 @@ shared_library("libclang") {
sources = [
"../../include/clang-c/Index.h",
- "ARCMigrate.cpp",
"BuildSystem.cpp",
"CIndex.cpp",
"CIndexCXX.cpp",
>From 55037e85a4dbbf7e62357885e94081fd7bb3d5a8 Mon Sep 17 00:00:00 2001
From: Sirraide <aeternalmail at gmail.com>
Date: Fri, 17 Jan 2025 03:57:04 +0100
Subject: [PATCH 5/7] Remove last remaining references to ARCMigrate
---
flang/docs/FlangDriver.md | 2 +-
.../llvm-project-overlay/clang/BUILD.bazel | 60 -------------------
.../clang/include/clang/Config/config.h | 1 -
3 files changed, 1 insertion(+), 62 deletions(-)
diff --git a/flang/docs/FlangDriver.md b/flang/docs/FlangDriver.md
index 23cbab30ee903e..309c5e2024dd84 100644
--- a/flang/docs/FlangDriver.md
+++ b/flang/docs/FlangDriver.md
@@ -119,7 +119,7 @@ Internally, a `clangDriver` based compiler driver works by creating actions
that correspond to various compilation phases, e.g. `PreprocessJobClass`,
`CompileJobClass`, `BackendJobClass` or `LinkJobClass` from the
`clang::driver::Action::ActionClass` enum. There are also other, more
-specialised actions, e.g. `MigrateJobClass` or `InputClass`, that do not map
+specialised actions, e.g. `InputClass`, that do not map
directly to common compilation steps. The actions to run are determined from
the supplied compiler flags, e.g.
diff --git a/utils/bazel/llvm-project-overlay/clang/BUILD.bazel b/utils/bazel/llvm-project-overlay/clang/BUILD.bazel
index e2babada500516..ab473abfbf3e33 100644
--- a/utils/bazel/llvm-project-overlay/clang/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/clang/BUILD.bazel
@@ -2177,33 +2177,6 @@ cc_library(
],
)
-cc_library(
- name = "arc_migrate",
- srcs = glob([
- "lib/ARCMigrate/*.cpp",
- "lib/ARCMigrate/*.h",
- ]),
- hdrs = glob(["include/clang/ARCMigrate/*.h"]),
- includes = ["include"],
- deps = [
- ":analysis",
- ":ast",
- ":basic",
- ":edit",
- ":frontend",
- ":frontend_rewrite",
- ":lex",
- ":parse",
- ":rewrite",
- ":sema",
- ":serialization",
- ":static_analyzer_checkers",
- ":static_analyzer_core",
- "//llvm:Support",
- "//llvm:TargetParser",
- ],
-)
-
cc_library(
name = "libclang_static",
srcs = glob([
@@ -2324,39 +2297,6 @@ cc_library(
],
)
-cc_binary(
- name = "arcmt-test",
- testonly = 1,
- srcs = ["tools/arcmt-test/arcmt-test.cpp"],
- stamp = 0,
- deps = [
- ":arc_migrate",
- ":ast",
- ":basic",
- ":frontend",
- ":frontend_rewrite",
- ":lex",
- "//llvm:Support",
- ],
-)
-
-cc_binary(
- name = "c-arcmt-test",
- testonly = 1,
- srcs = ["tools/c-arcmt-test/c-arcmt-test.c"],
- copts = select({
- "@platforms//os:windows": [],
- "//conditions:default": ["-std=gnu99"],
- }),
- stamp = 0,
- deps = [
- ":codegen",
- ":libclang",
- "//llvm:MC",
- "//llvm:Support",
- ],
-)
-
cc_binary(
name = "clang-import-test",
testonly = 1,
diff --git a/utils/bazel/llvm-project-overlay/clang/include/clang/Config/config.h b/utils/bazel/llvm-project-overlay/clang/include/clang/Config/config.h
index ac0d9eb24931f1..d74763ecbfd2d0 100644
--- a/utils/bazel/llvm-project-overlay/clang/include/clang/Config/config.h
+++ b/utils/bazel/llvm-project-overlay/clang/include/clang/Config/config.h
@@ -93,7 +93,6 @@
#define ENABLE_EXPERIMENTAL_NEW_PASS_MANAGER 0
/* Enable each functionality of modules */
-#define CLANG_ENABLE_ARCMT 1
#define CLANG_ENABLE_OBJC_REWRITER 1
#define CLANG_ENABLE_STATIC_ANALYZER 1
>From f7e547f6188ea61204c79608d873c1fbd77e4776 Mon Sep 17 00:00:00 2001
From: Sirraide <aeternalmail at gmail.com>
Date: Fri, 17 Jan 2025 06:00:31 +0100
Subject: [PATCH 6/7] Disable rewriter tests by default
---
clang/test/Rewriter/lit.local.cfg | 3 +--
clang/test/{Rewriter => Sema}/missing-dllimport.c | 0
2 files changed, 1 insertion(+), 2 deletions(-)
rename clang/test/{Rewriter => Sema}/missing-dllimport.c (100%)
diff --git a/clang/test/Rewriter/lit.local.cfg b/clang/test/Rewriter/lit.local.cfg
index f5e1d0349f52dc..8504dbb0e0fa90 100644
--- a/clang/test/Rewriter/lit.local.cfg
+++ b/clang/test/Rewriter/lit.local.cfg
@@ -1,3 +1,2 @@
# The Objective-C rewriters are currently grouped with ARCMT.
-if not config.root.clang_arcmt:
- config.unsupported = True
+config.unsupported = True
diff --git a/clang/test/Rewriter/missing-dllimport.c b/clang/test/Sema/missing-dllimport.c
similarity index 100%
rename from clang/test/Rewriter/missing-dllimport.c
rename to clang/test/Sema/missing-dllimport.c
>From 02ccfedea1c96e96c193c04f690da50cffe214e1 Mon Sep 17 00:00:00 2001
From: Sirraide <aeternalmail at gmail.com>
Date: Fri, 17 Jan 2025 06:16:19 +0100
Subject: [PATCH 7/7] Add CMake option for the rewriter
---
clang/CMakeLists.txt | 7 +++++++
clang/test/Rewriter/lit.local.cfg | 3 ++-
clang/test/lit.site.cfg.py.in | 1 +
3 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index 7050746e3a0380..773417476446ee 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -432,11 +432,18 @@ if(NOT LLVM_STATIC_LINK_CXX_STDLIB)
set(HAVE_CLANG_REPL_SUPPORT ON)
endif()
+option(CLANG_ENABLE_OBJC_REWRITER "Build the Objective-C rewriter tool" OFF)
+
option(CLANG_ENABLE_STATIC_ANALYZER
"Include static analyzer in clang binary." ON)
option(CLANG_ENABLE_PROTO_FUZZER "Build Clang protobuf fuzzer." OFF)
+if (DEFINED CLANG_ENABLE_ARCMT)
+ set(CLANG_ENABLE_OBJC_REWRITER ${CLANG_ENABLE_ARCMT})
+ message(DEPRECATION "'CLANG_ENABLE_ARCMT' is deprecated as ARCMigrate has been removed from Clang. Please use 'CLANG_ENABLE_OBJC_REWRITER' instead to enable or disable the Objective-C rewriter.")
+endif()
+
# This option is a stop-gap, we should commit to removing this as
# soon as possible. See discussion:
# https://discourse.llvm.org/t/rationale-for-removing-versioned-libclang-middle-ground-to-keep-it-behind-option/
diff --git a/clang/test/Rewriter/lit.local.cfg b/clang/test/Rewriter/lit.local.cfg
index 8504dbb0e0fa90..2fc1173d7ba31a 100644
--- a/clang/test/Rewriter/lit.local.cfg
+++ b/clang/test/Rewriter/lit.local.cfg
@@ -1,2 +1,3 @@
# The Objective-C rewriters are currently grouped with ARCMT.
-config.unsupported = True
+if not config.root.clang_objc_rewriter:
+ config.unsupported = True
diff --git a/clang/test/lit.site.cfg.py.in b/clang/test/lit.site.cfg.py.in
index 0e27f5e0bfc957..ae8b927624e23f 100644
--- a/clang/test/lit.site.cfg.py.in
+++ b/clang/test/lit.site.cfg.py.in
@@ -22,6 +22,7 @@ config.host_cxx = "@CMAKE_CXX_COMPILER@"
config.llvm_use_sanitizer = "@LLVM_USE_SANITIZER@"
config.have_zlib = @LLVM_ENABLE_ZLIB@
config.have_zstd = @LLVM_ENABLE_ZSTD@
+config.clang_objc_rewriter = "@CLANG_ENABLE_OBJC_REWRITER@" == "ON"
config.clang_default_pie_on_linux = @CLANG_DEFAULT_PIE_ON_LINUX@
config.clang_default_cxx_stdlib = "@CLANG_DEFAULT_CXX_STDLIB@"
config.clang_staticanalyzer = @CLANG_ENABLE_STATIC_ANALYZER@
More information about the flang-commits
mailing list